-
-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: move the slow load test from SDK to sample app code (#3777)
- Loading branch information
1 parent
fa409fe
commit 742d4b6
Showing
5 changed files
with
45 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
Samples/iOS-Swift/iOS-Swift/Profiling/NSObject+SentryAppSetup.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
* A category that overrides its `+[load]` method to deliberately take a long time to run, so we can | ||
* see it show up in profile stack traces. Categories' `+[load]` methods are guaranteed to be called | ||
* after all of a module's normal class' overrides, so we can be confident the ordering will always | ||
* have started the launch profiler by the time this runs. This must be done in Objective-C because | ||
* Swift does not allow implementation of `NSObject.load()`. | ||
*/ | ||
@interface | ||
NSObject (SentryAppSetup) | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
18 changes: 18 additions & 0 deletions
18
Samples/iOS-Swift/iOS-Swift/Profiling/NSObject+SentryAppSetup.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#import "NSObject+SentryAppSetup.h" | ||
|
||
@implementation | ||
NSObject (SentryAppSetup) | ||
+ (void)load | ||
{ | ||
NSLog(@"[iOS-Swift] Starting app launch work"); | ||
if ([NSProcessInfo.processInfo.arguments containsObject:@"--io.sentry.slow-load-method"]) { | ||
NSMutableString *a = [NSMutableString string]; | ||
// 1,000,000 iterations takes about 225 milliseconds in the iPhone 15 simulator on an | ||
// M2 macbook pro; we might have to adapt this for CI | ||
for (NSUInteger i = 0; i < 4000000; i++) { | ||
[a appendFormat:@"%d", arc4random() % 12345]; | ||
} | ||
} | ||
NSLog(@"[iOS-Swift] Finishing app launch work"); | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters