1. For Synchronous methods :
- (void)testPerformanceReverseString {
NSString *originalString = @"hi_my_name_is_siddharth";
[self measureBlock:^{
[self.someObject reverseString:originalString];
}];
}
2. For Asynchronous methods :
- (void)testPerformanceOfAsynchronousBlock {
[self measureMetrics:@[XCTPerformanceMetric_WallClockTime] automaticallyStartMeasuring:YES forBlock:^{
XCTestExpectation *expectation = [self expectationWithDescription:@"performanceTestWithResponse"];
[self.someObject doSomethingThatTakesSomeTimesWithCompletionBlock:^(NSString *result) {
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5.0 handler:^(NSError *error) {
}];
}];
}