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

3 comments:

  1. "a complete test could be interesting"

    So at least measure all the tasks shown on the benchmarks game - there are only a dozen.

    So at least do repeated measurements.

    So at least do measurements at more than on workload.

    So at least acknowledge that the benchmarks game tells you everywhere that "Go 6g 8g" are being measured.

    ReplyDelete
  2. You are right of course !
    I was just saying, it is worth adding gccgo to the complete bench.
    I was not expecting Go to be faster than the jvm on *any* benchmark before trying it.

    ReplyDelete
  3. "If you're interested in something not shown here then please take the program source code and the measurement scripts and publish your own measurements."

    http://shootout.alioth.debian.org/


    http://shootout.alioth.debian.org/help.php#languagex

    ReplyDelete