iOS How To: Logging Time Intervals
It’s always nice to know how well a method in your app is performing. Well here’s a quick tip on timing said methods. The result will output how long a method took from start to finish down to the millisecond.
First add the following to your .h file:
NSDate *recordStart;
Next, in the method you wish to time, add the follow code:
recordStart = [NSDate date]; // The code you wish to time here NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:recordStart]; NSLog(@"Stop Recording: %f", interval);
Comments are closed.