The Computer Language
Benchmarks Game

Go versus Java fastest programs

Back in April 2010, Russ Cox charitably suggested that only fannkuch-redux, fasta, k-nucleotide, mandlebrot, nbody, reverse-complement and spectral-norm were close to fair comparisons. As someone who implemented programming languages, his interest was "measuring the quality of the generated code when both compilers are presented with what amounts to the same program."

Differences in approach - to memory management, parallel programming, regex, arbitrary precision arithmetic, implementation technique - don't fit in that kind-of fair comparison — but we still have to deal with them.

These are only the fastest programs. There may be additional measurements for programs which seem more-like a fair comparison to you. Always look at the source code.

regex-redux
source secs mem gz busy cpu load
Go 6.84 340,376 810 9.43 30% 43% 13% 52%
Java 10.31 644,560 740 31.47 72% 72% 92% 70%
pidigits
source secs mem gz busy cpu load
Go 2.10 8,448 603 2.17 1% 48% 55% 0%
Java 3.07 39,320 938 3.31 2% 5% 3% 98%
mandelbrot
source secs mem gz busy cpu load
Go 5.47 31,088 905 21.77 100% 99% 99% 99%
Java 6.83 79,108 796 26.86 97% 99% 99% 99%
fasta
source secs mem gz busy cpu load
Go 2.08 3,560 1358 5.61 80% 37% 76% 78%
Java 2.22 45,172 2473 5.99 61% 50% 98% 60%
spectral-norm
source secs mem gz busy cpu load
Go 3.94 2,740 548 15.74 100% 100% 100% 100%
Java 4.19 36,680 950 16.31 98% 97% 97% 98%
n-body
source secs mem gz busy cpu load
Go 21.25 1,588 1310 21.48 0% 1% 100% 0%
Java 21.95 35,604 1429 22.75 2% 1% 100% 1%
reverse-complement
source secs mem gz busy cpu load
Go 3.83 1,782,940 1338 6.67 21% 74% 16% 62%
Java 3.16 712,368 2183 7.08 65% 47% 42% 70%
fannkuch-redux
source secs mem gz busy cpu load
Go 17.56 1,524 900 70.00 100% 100% 100% 100%
Java 14.33 34,888 1282 56.56 99% 98% 99% 98%
k-nucleotide
source secs mem gz busy cpu load
Go 11.77 160,184 1607 44.52 94% 98% 94% 92%
Java 9.33 447,976 1812 29.36 73% 83% 82% 77%
binary-trees
source secs mem gz busy cpu load
Go 25.17 361,152 1005 86.86 87% 89% 86% 84%
Java 8.32 953,620 835 28.37 95% 87% 81% 77%
Go

go version go1.13 linux/amd64

Java

openjdk 13 2019-09-17
OpenJDK Runtime Environment (build 13+33)
OpenJDK 64-Bit Server VM (build 13+33, mixed mode, sharing)