On Dec 24, 2010, at 8:19 PM, David Nolen wrote: > ((long double) end-start) / 1000.0
I don't think this math is correct. The units for the values returned by mach_absolute_time() are CPU-dependent: http://developer.apple.com/library/mac/#qa/qa2004/qa1398.html Using gettimeofday() on my 2.0 GHz Core 2 Duo Macbook, I get minima of ~3400 microseconds for unoptimized C, ~800 microseconds for -O2. #include <stdio.h> #include <sys/time.h> unsigned count_chars(char const * s) { unsigned count = 0; while (*s++) if (*s != ' ') ++count; return count; } int main(int argc, char** argv) { char const * s = "This is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long stringThis is a really long string"; unsigned i, j; struct timeval start, end; for (j = 0; j < 10; ++j) { gettimeofday(&start, 0); for (i = 0; i < 1000; ++i) count_chars(s); gettimeofday(&end, 0); printf("%u us\n", (unsigned)(1000000 * (end.tv_sec - start.tv_sec) + (end.tv_usec - start.tv_usec))); } return(0); } -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
