diff --git a/Samples/iOS-Swift/PerformanceBenchmarks/SDKPerformanceBenchmarkTests.swift b/Samples/iOS-Swift/PerformanceBenchmarks/SDKPerformanceBenchmarkTests.swift index 03e6d805a4a..6dbd7386604 100644 --- a/Samples/iOS-Swift/PerformanceBenchmarks/SDKPerformanceBenchmarkTests.swift +++ b/Samples/iOS-Swift/PerformanceBenchmarks/SDKPerformanceBenchmarkTests.swift @@ -1,5 +1,5 @@ -import XCTest import ObjectiveC +import XCTest class SDKPerformanceBenchmarkTests: XCTestCase { diff --git a/Samples/iOS-Swift/PerformanceBenchmarks/SentryDynamicTest.m b/Samples/iOS-Swift/PerformanceBenchmarks/SentryDynamicTest.m index 43522283ff9..268101d1135 100644 --- a/Samples/iOS-Swift/PerformanceBenchmarks/SentryDynamicTest.m +++ b/Samples/iOS-Swift/PerformanceBenchmarks/SentryDynamicTest.m @@ -1,5 +1,5 @@ -#import #import +#import // To get around the 15 minute timeout per test case on Sauce Labs. static NSUInteger SentrySDKPerformanceBenchmarkTestCases = 4; @@ -19,7 +19,8 @@ + (BOOL)addInstanceMethodWithSelectorName:(NSString *)selectorName block:(void ( @implementation SentrySDKPerformanceBenchmarkTests -+ (BOOL)addInstanceMethodWithSelectorName:(NSString *)selectorName block:(void (^)(id))block { ++ (BOOL)addInstanceMethodWithSelectorName:(NSString *)selectorName block:(void (^)(id))block +{ NSParameterAssert(selectorName); NSParameterAssert(block); @@ -31,17 +32,24 @@ + (BOOL)addInstanceMethodWithSelectorName:(NSString *)selectorName block:(void ( return class_addMethod(self, selector, myIMP, "v@:"); } -+ (void)initialize { ++ (void)initialize +{ allResults = [NSMutableArray array]; for (NSUInteger i = 0; i < SentrySDKPerformanceBenchmarkTestCases; i++) { - [self addInstanceMethodWithSelectorName:[NSString stringWithFormat:@"testCPUBenchmark%lu", (unsigned long)i] block:^(XCTestCase *testCase) { - [allResults addObjectsFromArray:[self _testCPUBenchmark]]; - }]; + [self addInstanceMethodWithSelectorName:[NSString stringWithFormat:@"testCPUBenchmark%lu", + (unsigned long)i] + block:^(XCTestCase *testCase) { + [allResults + addObjectsFromArray:[self _testCPUBenchmark]]; + }]; } } -- (void)tearDown { - if (allResults.count == SentrySDKPerformanceBenchmarkTestCases * SentrySDKPerformanceBenchmarkIterationsPerTestCase) { +- (void)tearDown +{ + if (allResults.count + == SentrySDKPerformanceBenchmarkTestCases + * SentrySDKPerformanceBenchmarkIterationsPerTestCase) { NSLog(@"All results begin"); NSLog(@"%@", allResults); NSLog(@"All results end"); @@ -50,8 +58,9 @@ - (void)tearDown { [super tearDown]; } -+ (BOOL)isSimulator { - NSOperatingSystemVersion ios9 = {9, 0, 0}; ++ (BOOL)isSimulator +{ + NSOperatingSystemVersion ios9 = { 9, 0, 0 }; NSProcessInfo *processInfo = [NSProcessInfo processInfo]; if ([processInfo isOperatingSystemAtLeastVersion:ios9]) { NSDictionary *environment = [processInfo environment]; @@ -63,13 +72,15 @@ + (BOOL)isSimulator { } } -+ (NSArray *)_testCPUBenchmark { -// XCTSkipIf([self isSimulator]); ++ (NSArray *)_testCPUBenchmark +{ + // XCTSkipIf([self isSimulator]); NSMutableArray *results = [NSMutableArray array]; for (NSUInteger j = 0; j < SentrySDKPerformanceBenchmarkIterationsPerTestCase; j++) { XCUIApplication *app = [[XCUIApplication alloc] init]; - app.launchArguments = [app.launchArguments arrayByAddingObject:@"--io.sentry.test.benchmarking"]; + app.launchArguments = + [app.launchArguments arrayByAddingObject:@"--io.sentry.test.benchmarking"]; [app launch]; [app.buttons[@"Performance scenarios"] tap]; @@ -98,8 +109,10 @@ + (BOOL)isSimulator { } double usagePercentage = benchmarkValueString.doubleValue; - // SentryBenchmarking.retrieveBenchmarks returns -1 if there aren't at least 2 samples to use for calculating deltas - XCTAssert(usagePercentage > 0, @"Failure to record enough CPU samples to calculate benchmark."); + // SentryBenchmarking.retrieveBenchmarks returns -1 if there aren't at least 2 samples to + // use for calculating deltas + XCTAssert( + usagePercentage > 0, @"Failure to record enough CPU samples to calculate benchmark."); [results addObject:@(usagePercentage)]; }