Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing Tools #13

Open
jsbean opened this issue Jul 12, 2017 · 0 comments
Open

Testing Tools #13

jsbean opened this issue Jul 12, 2017 · 0 comments

Comments

@jsbean
Copy link
Member

jsbean commented Jul 12, 2017

It is now worthwhile to interrogate the performance of some of the underlying data structures and algorithms for this project.

@brianlheim cooked up a really nice XCTestCase subclass for testing the linear complexity of a given operation over a given data structure, prepared in a given way.

I think this could be abstracted even further, making it painless to add performance tests in parallel to logic tests.

final class Measuring<T> {

    enum Result {
        case success
        case failure(expected: Complexity, result: String)
    }

    enum Complexity {
        case constant
        case logarithmic
        case linear
        case quasiLinear
        case quadratic
        case cubic
        case exponential
        case factorial
    }

    var resource: T

    init(_ resource: T, setUp: ((inout T) -> Void)? = nil) {
        self.resource = resource
        setUp?(&self.resource)
    }

    @discardableResult func assertComplexity <U> (
        _ complexity: Complexity,
        setUp: ((inout T) -> Void)? = nil,
        for operation: (T) -> U
    ) -> Measuring
    {
        // assert ...
        return self
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant