On Fri, Dec 24, 2010 at 7:32 PM, Alan Busby <thebu...@thebusby.com> wrote:
> On Fri, Dec 24, 2010 at 7:10 PM, Devrim Baris Acar > <devrimba...@gmail.com>wrote: > >> I guess it would be a better guess if you could includethe cpu type/speed >> for a rough reference... > > > It was on an Intel Xeon E5410 (2.33GHz), though like others have already > said there are a number of factors that affect performance. I was simply > curious of the relative speeds of the various code snippets on a production > server. > > Also, I tried the C version using unsigned long long ints (64bit) and it > was roughly the same speed. > On OS X at least the following program shows identical performance to the JVM using 64 bit integers, ~2000 nanoseconds on my machine. So Clojure is not too far behind. #import <Foundation/Foundation.h> #include "stdio.h" long long count_chars(const char* s) { long long count = 0; long long i; for(i=0; s[i]; s++) { if(s[i] != 32) { count++; } } return count; } int main(int argc, char** argv) { const char *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"; long long i; long long j; for(j = 0; j < 10; j++) { uint64_t start = mach_absolute_time(); for(i = 0; i < 1000; i++) { count_chars(s); } uint64_t end = mach_absolute_time(); printf("%Lf nanoseconds\n", ((long double) end-start) / 1000.0); } exit(0); } David -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en