// Start timer
NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate];
// Do something
for(double i=0; i < 1000000; i++ );
// Stop timer
NSTimeInterval endTime = [NSDate timeIntervalSinceReferenceDate];
// Get the elapsed time in milliseconds
NSTimeInterval elapsedTime = (endTime - startTime) * 1000;
// Send it to the Console
NSLog(@"Elapsed time in ms: %f", elapsedTime);
NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate];
// Do something
for(double i=0; i < 1000000; i++ );
// Stop timer
NSTimeInterval endTime = [NSDate timeIntervalSinceReferenceDate];
// Get the elapsed time in milliseconds
NSTimeInterval elapsedTime = (endTime - startTime) * 1000;
// Send it to the Console
NSLog(@"Elapsed time in ms: %f", elapsedTime);
// Declared In NSDate.h
// NSTimeInterval is always specified in seconds
// It yields sub-millisecond
// precision over a range of 10,000 years.
typedef double NSTimeInterval;