Measure iPhone application load time

I am optimizing the iPhone application for a very short download time, and I am wondering:

Is there a way to measure the loading time of the iPhone application from the moment the user clicks the icon while the application is being used (or at least calls the -viewDidLoad call)?

Ideally, this will work in the device and the simulator, but if someone found a way to measure this time exclusively in the simulator, which, at least, would be the starting point.

And no; "stopwatch" or "one Mississippi, two Mississippi" do not count. :-)

+6
optimization iphone
source share
3 answers

Start the timer in the init method of the application delegate, and then stop when viewDidAppear: -

Start timer with: -

NSDate *startTime = [NSDate date]; 

... and end with: -

 NSTimeInterval elapsedTime = [startTime timeIntervalSinceNow]; NSLog(@"Startup tasks: %f", -elapsedTime); 

This will not start from the moment you click the icon, but should be pretty early in your work. You could probably look at an earlier time in the logs released in the debugger console?

+2
source share

As part of WWDC 2016, Apple announced a new environment variable, available as part of beta 2, which will help you record the launch time of the application.

One of the problems with the above answers is that they do not take into account the main time at which the images are loaded, and the bindings overflow and snap.

If you add the variable DYLD_PRINT_STATISTICS = 1 you will get the preliminary main time printed on the console.

Session 406 from WWDC 2016 goes into this use of the variable and how to interpret the results.

+2
source share

Put NSLog(@"started loading"); back to top applicationDidFinishLauching and NSLog(@"finished loading"); in the viewDidAppear of the application delegate. In the debugger console you will get something like

 2010-11-21 17:16:06.278 Phy[9157:207] started loading 2010-11-21 17:16:06.301 Phy[9157:207] finished loading 

Therefore, it took 0.03 seconds to run the simulation application.

+1
source share

All Articles