gettimeofday()
to get sub-second granularity for timing:#include <sys/time.h> struct timeval start, end; ... gettimeofday (&start, NULL); ... the code you're timing gettimeofday (&end, NULL); double fstart, fend; fstart = (start.tv_sec * 1000000.0 + start.tv_usec) / 1000000.0; fend = (end.tv_sec * 1000000.0 + end.tv_usec) / 1000000.0; NSLog (@"it took %f seconds", fend - fstart);
time_t now; now = time(NULL); struct tm *tm; tm = localtime (&now); char timestamp[200]; strftime (timestamp, 200, "%m/%d/%Y-%H:%M", tm);