Application targets for the dn-m project.
dn-m / performancetesting Goto Github PK
View Code? Open in Web Editor NEWStructures for testing performance characteristics of data structures and algorithms
License: MIT License
Structures for testing performance characteristics of data structures and algorithms
License: MIT License
Following some changes we made in other places, would it be reasonable to change:
enum Complexity {
...
case customComplexity(inverseFunction: (Double) -> Double)
}
to:
enum Complexity {
...
case custom(inverse: (Double) -> Double)
}
In both cases (customComplexity
and inverseFunction
), the second word functions to expose the type (in some sense) of the value (Complexity
and Function
, respectively). This type is exposed inherently by the type system.
These cases haven't yet been touched:
e.g., gift wrapping algorithm is O(nh)
.
reading:
http://www.ahinson.com/algorithms_general/Sections/InterpolationRegression/RegressionPlanar.pdf
other possible avenues for exploration:
There are several points where Darwin
is imported.
-Sources/PerformanceTesting/DataSet.swift
-Sources/PerformanceTesting/Complexity.swift
-Sources/PerformanceTesting/Scale.swift
In order to serve Linux, conditionally import Glibc
.
Currently, mapDataForLinearFit(_:)
is on Complexity
. I may be wrong, but it seems like it is more in the domain of the Benchmark
than Complexity
.
Instead, what if we move it to Benchmark
:
extension Benchmark {
func mappedForLinearFit(complexity: Complexity) -> Benchmark
}
First, I think we should keep the linear
case under the same roof as all of the others, so that assertConstantTimePerformance
is not a different public function.
Instead, for now, we should do a case let .constant = complexity { assertConstantTimePerformance(...) }
With that said, I think we could clarify the path of types.
Perhaps we could rename this to:
func assert(_ benchmark: Benchmark, isIn complexity: Complexity, minimumCorrelation: Double = 0.9)
Instead of using global state, we could have the user inject Logging
(currently, Configuration
), providing a reasonable default (which I would propose to be .none
).
Both time
and benchmark
can be nouns / verbs, which can be a bit confusing.
Currently, they are being used as verbs, though they are functions with return values. Perhaps we can orient the names around the type of the return value, instead of what it takes to create that value.
Currently, we have things like makeArray(size:)
, makeDictionary(size:)
, makeSet(size:)
nested within our tests here.
Let's move these to PerformanceTestCase
?
The extension properties sum
and average
over Array<Double>
currently at the end of PerformanceTestCase.swift
could help streamline some of the code in LinearRegression.swift
.
Let's move those out into their own file and use 'em?
Currently, Benchmark
is just a typealias
for [(Double,Double)]
.
I think it could be nice to package up all of the information the performance benchmark of a single operation. The API could fall out like this:
struct Trial {
let size: Int
let time: Double /* Seconds */
}
struct Benchmark {
let trials: [Trial]
let targetComplexity: Complexity
}
Right now, there is a slight dissonance to me regarding what a Scale
is, and what testPoints
are. They seem to be at two different levels of abstraction, seen from the viewpoint of the function call.
What if we implemented Scale
as such:
enum Scale {
case tiny
case small
case medium
case large
}
extension Scale {
var testPoints: [Double] {
switch self {
case tiny:
exponentialSeries(size: 10, from: 5, to: 100)
...
}
}
}
It seems that the instance methods on PerformanceTestCase
(benchmark
, assertPerformance
, etc.) don't have any dependencies on the PerformanceTestCase
class.
I'm not sure this will work, but it could be worthwhile to move these methods out into free functions, calling XCTAssert
(which is...a macro?).
The function calls would look identical at the call site, without requiring users to subclass PerformanceTestCase
. I forgot I had to subclass PerformanceTestCase
myself.
It is used just a few times in SetTests
, where it looks like it may be replaced with some other logic.
In trying to get rid of it, though, Swift gives me a very curious error at the location within the test:
Cannot use mutating member on immutable value: 'array' is a 'let' constant
This error or only seems to occur if the type is (inout Structure)
, but not (inout Structure, Double)
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.