Skip to content

Instantly share code, notes, and snippets.

@marslin1220
Created February 24, 2020 07:16
Show Gist options
  • Save marslin1220/4b445f7ba3d5f44393fb3cc835a8d699 to your computer and use it in GitHub Desktop.
Save marslin1220/4b445f7ba3d5f44393fb3cc835a8d699 to your computer and use it in GitHub Desktop.
/**
* @protocol XCTMetric
* Defines a protocol which may be used with the -measureWithMetrics* methods on XCTestCase.
*
* @discussion
* Classes conforming to XCTMetric must also adopt NSCopying, as a unique metric instance is copied for each iteration.
*/
public protocol XCTMetric : NSCopying, NSObjectProtocol {
/**
* @method -reportMeasurementsFromStartTime:toEndTime:error:
* Report measurements for the iteration that started and ended at the specified times.
*
* @discussion
* Called after -didStopMeasuring has been invoked and when XCTest is ready to gather
* the measurements that were collected. You can truncate the data accumulated to be as
* accurate as possible with the start and end times.
*/
func reportMeasurements(from startTime: XCTPerformanceMeasurementTimestamp, to endTime: XCTPerformanceMeasurementTimestamp) throws -> [XCTPerformanceMeasurement]
/*
* @method -willBeginMeasuring
* Called every iteration just before the measure block is about to be invoked.
* You should begin measuring when this is called.
*/
optional func willBeginMeasuring()
/*
* @method -didStopMeasuring
* Called after the measure block's invocation. You should stop measuring when
* this is called.
*/
optional func didStopMeasuring()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment