Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code to measure EXACT execution time inside code on iPad or Phone?

Tags:

Is is any difference between using mach_absolute_time and the simple NSDate method explained by golden eagle below?

Here's an excellent explanation of using the mach approach...

How do I accurately time how long it takes to call a function on the iPhone?

and

Measure time between library call and callback

like image 613
Fattie Avatar asked Jan 23 '11 11:01

Fattie


1 Answers

loop   {    NSDate *start = [NSDate date];    // a considerable amount of difficult processing here   // a considerable amount of difficult processing here   // a considerable amount of difficult processing here     NSDate *methodFinish = [NSDate date];    NSTimeInterval executionTime = [methodFinish timeIntervalSinceDate:start];     NSLog(@"Execution Time: %f", executionTime);   } 

Should work.

like image 118
Aurum Aquila Avatar answered Sep 24 '22 15:09

Aurum Aquila