2012-09-19

The Go Language is faster than the computer language benchmarks game thinks it is

Note : yes this is anecdotal but my point is that a complete test could be interesting.
I noticed that the computer language benchmarks compiled Go only with the default toolchain compiler
I was surprised at how slow the Go language was so I tried it myself quickly on my sandybridge laptop
For example on this simple nbody test example.
# fetch nbody.c and nbody.go
$ gccgo -pipe -Wall -O3 -fomit-frame-pointer -march=native -mfpmath=sse -msse3 -o nbody.go_gcc nbody.go
$ go build nbody.go; mv nbody nbody.go_gc
$ gcc -pipe -Wall -O3 -fomit-frame-pointer -march=native -mfpmath=sse -msse3 nbody.c -o nbody.gcc_run -lm

# so the reference 
$ time ./nbody.gcc_run 50000000 
-0.169075164
-0.169059907
./nbody.gcc_run 50000000  8.13s user 0.00s system 99% cpu 8.135 total

# The toolkit version
$ time ./nbody.go_gc 50000000
-0.169075164
-0.169059907
./nbody.go_gc 50000000  14.27s user 0.00s system 99% cpu 14.285 total

# The fair comparison : same compiler same options as C
$ time ./nbody.go_gcc 50000000
-0.169075164
-0.169059907
./nbody.go_gcc 50000000  8.31s user 0.01s system 99% cpu 8.324 total
Lang C Go compiler Go Gcc
Results 8.135 14.285 8.324
My normalized results to 1.5 for C 1.5 2.63 1.53
Benchmark Game normalized results 1.5 2.3 ?
So Go should be between C and Clean, smoking scala, clojure, java and lisp.
Edit: Took the wrong timing values in the table, but it doesn't change the ratios