XCTAssertMetric

public struct XCTAssertMetric<Identifier> where Identifier : XCTAssertMetricIdentifier

Represents the type of metric you can make assertions for, like cpu or memory.

Use XCTAssertMetric(_:_:_:_:file:line:) to write assertions for performance metrics you measured using for example measure(metrics:block:).

  • cpu

    Can be used to make assertions for the collected XCTCPUMetrics.

    Declaration

    Swift

    static var cpu: XCTAssertMetric<XCTAssertCpuIdentifier> { get }
  • Can be used to make assertions for the collected XCTMemoryMetrics.

    Declaration

    Swift

    static var memory: XCTAssertMetric<XCTAssertMemoryIdentifier> { get }
  • Can be used to make assertions for the collected XCTStorageMetrics.

    Declaration

    Swift

    static var disk: XCTAssertMetric<XCTAssertDiskIdentifier> { get }
  • Can be used to make assertions for the collected XCTClockMetrics.

    Declaration

    Swift

    static var clock: XCTAssertMetric<XCTAssertClockIdentifier> { get }
  • Represents the type of value what you can assert for.

    The following example makes an assertion for the average(maximum:) of the time a code takes to run.

    measure {
      let _ = (1..<1000).reduce(0, +)
    }
    XCTAssertMetric(.clock, .timeMonotonic, .average(maximum: 0.001))
    
    See more

    Declaration

    Swift

    enum Aspect