Skip to content

Testing Tools #13

Description

@jsbean

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
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions