To roughly measure the time necessary to do a certain action:
CFTimeInterval startTime = CFAbsoluteTimeGetCurrent(); CFTimeInterval duration = CFAbsoluteTimeGetCurrent() - startTime; NSLog(@"Parse time: %f seconds", duration);
This is easier than using mach_absolute_time(), because if you want human-readable time, that function its return value has to be converted (to seconds or what have you).
Edit: for more information on this topic, see Benchmarking on NSHipster.
Note that you are not allowed to use mach_absolute_time() in App Store code.
The following standard timestamp is really useful for logging the full time:
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateFormat:@"dd/MM/yyyy HH:mm:ss"]; NSString *timestamp = [dateFormatter stringFromDate:[NSDate date]];
To get the current second:
int sec = [[[NSCalendar currentCalendar] components:NSSecondCalendarUnit fromDate:[NSDate date]] second];