Timer

public extension Timer
  • Convenience for measuring duration of a closure.

    Declaration

    Swift

    @inlinable
    static func measure<T>(label: String, dimensions: [(String, String)] = [], body: @escaping () throws -> T) rethrows -> T

    Parameters

    label

    The label for the Timer.

    dimensions

    The dimensions for the Timer.

    body

    Closure to run & record.

  • Record the time interval (with nanosecond precision) between the passed since dispatch time and end dispatch time.

    Declaration

    Swift

    func recordInterval(since: DispatchTime, end: DispatchTime = .now())

    Parameters

    since

    Start of the interval as DispatchTime.

    end

    End of the interval, defaulting to .now().

  • Convenience for recording a duration based on TimeInterval.

    Declaration

    Swift

    @inlinable
    func record(_ duration: TimeInterval)

    Parameters

    duration

    The duration to record.

  • Convenience for recording a duration based on DispatchTimeInterval.

    Declaration

    Swift

    @inlinable
    func record(_ duration: DispatchTimeInterval)

    Parameters

    duration

    The duration to record.