In September 2018, Apple introduced os_SignPOST, which works with Instruments to display visualizations of WWDC video Measuring Performance Using Logging

Environment version

Xcode Version: 13

Mac OS Version 12.0.1

Support version

Xcode Version: 10+

iOS 12+

1. Write the start and end code

/// Time Pofier flag Time + (os_log_t)creatWithBundleId:(const char *)bundleId key:(const char *)key { return os_log_create(bundleId, key); } // start + (void)beginTime:(os_log_t)logger {if (@available(iOS 12.0, *)) { os_signpost_id_t signPostId = os_signpost_id_make_with_pointer(logger,sin); Os_signpost_interval_begin (Logger, signPostId, "Launch","%{public}s",""); Os_signpost_interval_end (Logger, signPostId, "Launch"); }} /// end - (void)endTime:(os_log_t)logger {if (@available(iOS 12.0, *)) { os_signpost_id_t signPostId = os_signpost_id_make_with_pointer(logger,sin); os_signpost_interval_end(logger, signPostId, "Launch"); }}Copy the code

2. Write the method of time consuming statistics

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { os_log_t log = [LGClangTools creatWithBundleId:"com.ruisha.com" key:"didFinishLaunch"]; [LGClangTools beginTime:log]; . The code... [LGClangTools endTime:log]; return YES; }Copy the code

3. Add os_signpost

Open Instruments and select TimeProfile

4. Tap the upper left corner to start recording

5. Go to os_SIGNPOST and expand it to find the bundleId(@com.sharui.com in my case)