Java VS Go benchmarks

Current benchmark data was generated on Thu Sep 22 2022, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz (Model 106)

* -m in a file name stands for multi-threading or multi-processing

* -i in a file name stands for direct intrinsics usage. (Usage of simd intrinsics via libraries is not counted)

* -ffi in a file name stands for non-stdlib FFI usage

* (You may find time < time(user) + time(sys) for some non-parallelized programs, the overhead is from GC or JIT compiler, which are allowed to take advantage of multi-cores as that's more close to real-world scenarios.)

binarytrees

Input: 18

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2.java 664ms 1.0ms 413.9MB 690ms 83ms openjdk 20
java 2.java 690ms 43ms 602.5MB 673ms 120ms openjdk 19
java 2.java 744ms 45ms 680.0MB 807ms 163ms graal/jvm 17.0.4
java 2.java 1277ms 28ms 1069.2MB 903ms 583ms openjdk/zgc 19
go 1.go 3006ms 7.3ms 46.0MB 4327ms 47ms go 1.19.1
go 1.go 4239ms 23ms 37.9MB 4220ms 0ms tinygo 0.25.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2.java 164ms 6.4ms 109.4MB 170ms 23ms openjdk 19
java 2.java 174ms 14ms 111.4MB 163ms 37ms openjdk 20
java 2-m.java 182ms 6.2ms 168.4MB 240ms 40ms graal/jvm 17.0.4
go 1.go 259ms 1.5ms 8.1MB 337ms 3ms go 1.19.1
java 2.java 300ms 5.7ms 243.7MB 187ms 153ms openjdk/zgc 19
go 1.go 349ms 0.6ms 6.0MB 340ms 0ms tinygo 0.25.0

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 168ms 2.7ms 8.5MB 157ms 0ms go 1.19.1
java 1-m.java 707ms 9.0ms 265.3MB 1220ms 77ms graal/jvm 17.0.4
java 1-m.java 855ms 53ms 199.0MB 1527ms 47ms openjdk 19
java 1-m.java 865ms 87ms 204.6MB 1517ms 80ms openjdk 20
java 1-m.java 1039ms 68ms 472.6MB 1557ms 310ms openjdk/zgc 19

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 49ms 1.8ms 8.2MB 37ms 0ms go 1.19.1
java 1-m.java 376ms 7.7ms 183.4MB 617ms 47ms graal/jvm 17.0.4
java 1-m.java 417ms 22ms 115.4MB 690ms 43ms openjdk 19
java 1-m.java 456ms 17ms 118.7MB 757ms 37ms openjdk 20
java 1-m.java 547ms 23ms 209.2MB 777ms 153ms openjdk/zgc 19

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3-m.go 1443ms 1.4ms 3.0MB 2800ms 0ms go 1.19.1
java 1-m.java 1676ms 23ms 100.6MB 3180ms 33ms graal/jvm 17.0.4
java 1-m.java 1702ms 47ms 43.8MB 3257ms 17ms openjdk 20
java 1-m.java 1722ms 18ms 43.8MB 3290ms 13ms openjdk 19
java 1-m.java 1731ms 12ms 42.4MB 3233ms 50ms openjdk/zgc 19
go 3.go 2937ms 1.2ms 49.1MB 2913ms 7ms tinygo 0.25.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3-m.go 147ms 2.4ms 3.0MB 223ms 0ms go 1.19.1
java 1-m.java 272ms 3.4ms 42.5MB 443ms 13ms openjdk 20
java 1-m.java 273ms 6.2ms 42.2MB 437ms 10ms openjdk 19
java 1-m.java 285ms 13ms 91.6MB 450ms 17ms graal/jvm 17.0.4
go 3.go 314ms 1.1ms 49.9MB 283ms 7ms tinygo 0.25.0
java 1-m.java 315ms 4.4ms 42.5MB 450ms 50ms openjdk/zgc 19

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3-m.go 242ms 1.6ms 2.9MB 440ms 0ms go 1.19.1
java 4.java 510ms 2.3ms 44.0MB 587ms 17ms openjdk 20
java 4.java 515ms 7.4ms 43.3MB 590ms 17ms openjdk 19
java 4.java 558ms 6.8ms 41.8MB 587ms 67ms openjdk/zgc 19
java 4-m.java 618ms 4.2ms 119.8MB 937ms 27ms graal/jvm 17.0.4

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 30ms 0.1ms 2.9MB 40ms 0ms go 1.19.1
java 4.java 141ms 1.4ms 42.9MB 160ms 20ms openjdk 20
java 4.java 144ms 4.0ms 41.2MB 177ms 7ms openjdk 19
java 4.java 154ms 7.2ms 90.9MB 193ms 23ms graal/jvm 17.0.4
java 4.java 184ms 4.4ms 43.1MB 167ms 50ms openjdk/zgc 19

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 1.6ms 0.9ms 0.0MB 0ms 0ms tinygo 0.25.0
go 1.go 2.6ms 0.5ms 2.9MB 0ms 0ms go 1.19.1
java 1.java 70ms 3.1ms 63.4MB 70ms 10ms graal/jvm 17.0.4
java 1.java 78ms 5.0ms 42.7MB 78ms 6ms openjdk 20
java 1.java 82ms 3.6ms 40.8MB 78ms 8ms openjdk 19
java 1.java 119ms 4.8ms 39.9MB 78ms 52ms openjdk/zgc 19

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 3-m.java 1454ms 18ms 114.9MB 2660ms 40ms openjdk 20
java 3-m.java 1468ms 27ms 117.1MB 2693ms 47ms openjdk 19
go 7-m.go 1505ms 5.6ms 42.6MB 2817ms 23ms go 1.19.1
java 3-m.java 1599ms 70ms 191.0MB 2963ms 53ms graal/jvm 17.0.4
java 3-m.java 1935ms 42ms 175.5MB 3417ms 150ms openjdk/zgc 19

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 7-m.go 224ms 3.0ms 22.4MB 363ms 17ms go 1.19.1
java 3-m.java 459ms 22ms 93.2MB 763ms 27ms openjdk 20
java 3-m.java 475ms 7.0ms 94.5MB 717ms 80ms openjdk/zgc 19
java 3-m.java 487ms 66ms 96.8MB 830ms 23ms openjdk 19
java 3-m.java 679ms 63ms 161.5MB 1190ms 40ms graal/jvm 17.0.4

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1b.java 1401ms 6.2ms 50.4MB 1487ms 10ms openjdk 20
java 1b.java 1420ms 20ms 50.1MB 1510ms 17ms openjdk 19
java 1b.java 1461ms 14ms 47.6MB 1520ms 50ms openjdk/zgc 19
java 1b.java 1467ms 10ms 120.7MB 1620ms 37ms graal/jvm 17.0.4
java 1a.java 1529ms 0.9ms 48.5MB 1617ms 10ms openjdk 19
java 1a.java 1537ms 4.1ms 50.9MB 1610ms 20ms openjdk 20
java 1a.java 1573ms 2.7ms 47.6MB 1617ms 53ms openjdk/zgc 19
java 1a.java 1577ms 3.0ms 112.9MB 1680ms 27ms graal/jvm 17.0.4
java 1.java 2025ms 21ms 165.5MB 2130ms 30ms graal/jvm 17.0.4
java 1.java 2115ms 8.5ms 198.3MB 2173ms 37ms openjdk 20
java 1.java 2138ms 4.5ms 192.1MB 2200ms 33ms openjdk 19
java 1.java 2503ms 14ms 581.3MB 2243ms 367ms openjdk/zgc 19
go 1.go 4105ms 9.6ms 7.3MB 4087ms 3ms go 1.19.1
go 1.go timeout 0.0ms 0.0MB 0ms 0ms tinygo 0.25.0
java 2.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 19
java 2.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 20
java 2.java timeout 0.0ms 0.0MB 0ms 0ms openjdk/zgc 19

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 172ms 1.6ms 2.8MB 160ms 0ms go 1.19.1
java 1b.java 210ms 4.8ms 46.6MB 283ms 17ms openjdk 19
java 1b.java 210ms 4.2ms 46.7MB 287ms 10ms openjdk 20
java 1a.java 214ms 1.9ms 47.1MB 280ms 10ms openjdk 19
java 1a.java 215ms 15ms 46.8MB 283ms 13ms openjdk 20
java 1.java 216ms 6.0ms 95.9MB 263ms 23ms openjdk 19
java 1.java 218ms 4.9ms 99.6MB 270ms 17ms openjdk 20
java 1a.java 222ms 4.8ms 101.7MB 293ms 30ms graal/jvm 17.0.4
java 1.java 241ms 3.5ms 107.0MB 307ms 40ms graal/jvm 17.0.4
go 1.go 248ms 4.4ms 0.0MB 240ms 0ms tinygo 0.25.0
java 1b.java 260ms 24ms 45.7MB 300ms 57ms openjdk/zgc 19
java 1a.java 274ms 51ms 47.2MB 320ms 50ms openjdk/zgc 19
java 1b-m.java 281ms 24ms 118.7MB 413ms 43ms graal/jvm 17.0.4
java 1.java 287ms 18ms 113.1MB 293ms 77ms openjdk/zgc 19
java 2.java 761ms 27ms 547.8MB 943ms 127ms openjdk 19
java 2.java 766ms 10ms 566.9MB 947ms 110ms openjdk 20
java 2.java 1367ms 20ms 1026.7MB 1000ms 660ms openjdk/zgc 19

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 495ms 5.0ms 291.5MB 513ms 73ms openjdk 20
java 1.java 512ms 13ms 367.3MB 520ms 83ms openjdk 19
java 1.java 549ms 9.4ms 361.3MB 697ms 87ms graal/jvm 17.0.4
java 1.java 932ms 20ms 758.5MB 643ms 430ms openjdk/zgc 19
go 1.go 1976ms 5.3ms 48.1MB 2803ms 43ms go 1.19.1
go 2.go 2305ms 5.9ms 41.3MB 3270ms 43ms go 1.19.1
go 1.go 3286ms 4.0ms 212.1MB 3233ms 33ms tinygo 0.25.0
go 2.go timeout 0.0ms 0.0MB 0ms 0ms tinygo 0.25.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 219ms 2.1ms 173.3MB 243ms 37ms openjdk 19
java 1.java 223ms 6.1ms 174.3MB 237ms 43ms openjdk 20
java 1-m.java 267ms 8.9ms 245.9MB 380ms 60ms graal/jvm 17.0.4
go 1.go 413ms 2.9ms 12.3MB 567ms 13ms go 1.19.1
java 1.java 433ms 6.0ms 353.0MB 260ms 230ms openjdk/zgc 19
go 2.go 485ms 2.0ms 13.0MB 663ms 17ms go 1.19.1
go 1.go 792ms 1.5ms 52.1MB 773ms 3ms tinygo 0.25.0
go 2.go 1083ms 3.6ms 39.4MB 1057ms 10ms tinygo 0.25.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 455ms 2.1ms 2.9MB 443ms 0ms go 1.19.1
java 1.java 539ms 2.8ms 86.1MB 583ms 20ms graal/jvm 17.0.4
java 1.java 558ms 2.9ms 44.4MB 563ms 23ms openjdk 20
java 1.java 558ms 2.6ms 42.4MB 577ms 13ms openjdk 19
java 1.java 614ms 4.4ms 42.3MB 590ms 57ms openjdk/zgc 19
go 1.go 843ms 0.9ms 0.0MB 830ms 0ms tinygo 0.25.0
java 2.java 1887ms 33ms 538.3MB 1923ms 107ms openjdk 19
java 2.java 1923ms 9.6ms 563.7MB 1950ms 127ms openjdk 20
java 2.java 2582ms 4.7ms 1219.4MB 2027ms 753ms openjdk/zgc 19

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 50ms 1.4ms 2.9MB 40ms 0ms go 1.19.1
go 1.go 88ms 2.5ms 0.0MB 80ms 0ms tinygo 0.25.0
java 1.java 142ms 3.9ms 42.7MB 157ms 17ms openjdk 20
java 1.java 144ms 1.6ms 86.4MB 190ms 20ms graal/jvm 17.0.4
java 1.java 146ms 5.8ms 42.7MB 167ms 10ms openjdk 19
java 1.java 190ms 3.5ms 42.2MB 160ms 57ms openjdk/zgc 19
java 2.java 414ms 4.9ms 363.3MB 493ms 70ms openjdk 20
java 2.java 417ms 2.1ms 355.0MB 483ms 73ms openjdk 19
java 2.java 676ms 0.7ms 455.4MB 547ms 290ms openjdk/zgc 19

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 2.go 621ms 1.4ms 17.1MB 603ms 0ms tinygo 0.25.0
go 1.go 759ms 9.3ms 73.5MB 737ms 10ms go 1.19.1
java 1.java 781ms 22ms 88.1MB 807ms 23ms openjdk 20
go 1.go 797ms 15ms 42.5MB 777ms 7ms tinygo 0.25.0
go 2.go 905ms 4.0ms 19.8MB 890ms 7ms go 1.19.1
java 1.java 922ms 29ms 84.4MB 943ms 23ms openjdk 19
java 1.java 982ms 26ms 110.6MB 940ms 87ms openjdk/zgc 19
java 2.java 1003ms 4.6ms 52.7MB 1043ms 13ms openjdk 20
java 2.java 1028ms 5.3ms 52.2MB 1010ms 60ms openjdk/zgc 19
java 2.java 1039ms 37ms 54.3MB 1077ms 17ms openjdk 19
java 1-m.java 1472ms 70ms 163.9MB 2240ms 53ms graal/jvm 17.0.4
java 2-m.java 1848ms 24ms 128.2MB 3400ms 50ms graal/jvm 17.0.4

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 129ms 1.0ms 13.6MB 120ms 0ms tinygo 0.25.0
go 1.go 131ms 3.7ms 23.9MB 117ms 3ms go 1.19.1
go 2.go 148ms 1.7ms 5.4MB 140ms 0ms tinygo 0.25.0
go 2.go 216ms 2.6ms 7.6MB 203ms 0ms go 1.19.1
java 1.java 236ms 2.7ms 62.5MB 270ms 13ms openjdk 20
java 1.java 237ms 4.6ms 62.3MB 257ms 27ms openjdk 19
java 1.java 280ms 5.4ms 60.9MB 263ms 60ms openjdk/zgc 19
java 2.java 325ms 6.4ms 48.8MB 363ms 10ms openjdk 20
java 2.java 326ms 0.8ms 48.2MB 360ms 17ms openjdk 19
java 1-m.java 332ms 8.9ms 135.3MB 470ms 43ms graal/jvm 17.0.4
java 2.java 360ms 3.3ms 44.2MB 353ms 50ms openjdk/zgc 19
java 2-m.java 611ms 3.6ms 127.9MB 1100ms 33ms graal/jvm 17.0.4

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 8.go 1424ms 4.4ms 8.5MB 1400ms 7ms go 1.19.1
java 1.java 4981ms 1.4ms 374.1MB 5360ms 117ms graal/jvm 17.0.4
java 1.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 19
java 1.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 20
java 1.java timeout 0.0ms 0.0MB 0ms 0ms openjdk/zgc 19

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 8.go 341ms 0.8ms 8.4MB 323ms 3ms go 1.19.1
java 1.java 1362ms 9.0ms 390.5MB 1710ms 97ms graal/jvm 17.0.4
java 1.java 1411ms 34ms 288.1MB 1777ms 70ms openjdk 19
java 1.java 1453ms 6.4ms 302.3MB 1863ms 57ms openjdk 20
java 1.java 1946ms 8.4ms 924.1MB 1807ms 637ms openjdk/zgc 19

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go timeout 0.0ms 0.0MB 0ms 0ms go 1.19.1
go 3.go timeout 0.0ms 0.0MB 0ms 0ms tinygo 0.25.0
java 3.java timeout 0.0ms 0.0MB 0ms 0ms graal/jvm 17.0.4
java 3.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 19
java 3.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 20
java 3.java timeout 0.0ms 0.0MB 0ms 0ms openjdk/zgc 19

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 3.java 1050ms 10ms 187.5MB 1453ms 50ms graal/jvm 17.0.4
java 3.java 1073ms 14ms 112.0MB 1417ms 40ms openjdk 20
java 3.java 1079ms 23ms 109.8MB 1417ms 43ms openjdk 19
java 3.java 1166ms 16ms 158.0MB 1343ms 123ms openjdk/zgc 19
go 3.go 2503ms 23ms 18.2MB 2473ms 33ms go 1.19.1
go 3.go timeout 0.0ms 0.0MB 0ms 0ms tinygo 0.25.0

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 4-m.go 2511ms 29ms 5.4MB 4843ms 7ms go 1.19.1
java 2-m.java 4306ms 8.2ms 104.9MB 8330ms 30ms graal/jvm 17.0.4
go 1.go 4887ms 5.0ms 5.5MB 4870ms 3ms go 1.19.1
go 1.go timeout 0.0ms 0.0MB 0ms 0ms tinygo 0.25.0
java 2.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 19
java 2.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 20
java 2.java timeout 0.0ms 0.0MB 0ms 0ms openjdk/zgc 19

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 4-m.go 630ms 0.5ms 4.9MB 1200ms 0ms go 1.19.1
go 1.go 1229ms 3.9ms 2.9MB 1213ms 3ms go 1.19.1
java 2-m.java 1270ms 5.6ms 108.9MB 2323ms 37ms graal/jvm 17.0.4
java 2-m.java 1647ms 83ms 44.4MB 3100ms 20ms openjdk 19
java 2-m.java 1733ms 180ms 44.2MB 3290ms 17ms openjdk 20
java 2-m.java 1755ms 197ms 42.6MB 3250ms 57ms openjdk/zgc 19
go 1.go 2577ms 1.0ms 0.0MB 2560ms 0ms tinygo 0.25.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 4-m.go 166ms 0.9ms 4.9MB 293ms 0ms go 1.19.1
go 1.go 309ms 0.2ms 2.9MB 300ms 0ms go 1.19.1
java 2-m.java 446ms 11ms 98.3MB 743ms 40ms graal/jvm 17.0.4
java 2-m.java 563ms 42ms 44.2MB 1017ms 10ms openjdk 20
java 2-m.java 582ms 12ms 44.6MB 1037ms 17ms openjdk 19
java 2-m.java 647ms 16ms 44.4MB 1083ms 50ms openjdk/zgc 19
go 1.go 648ms 0.7ms 0.0MB 637ms 0ms tinygo 0.25.0

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1-m.go 787ms 149ms 13.6MB 1523ms 3ms go 1.19.1
go 1.go 1694ms 7.1ms 257.2MB 1627ms 53ms tinygo 0.25.0
java 1-m.java 4259ms 124ms 932.0MB 7657ms 480ms openjdk/zgc 19
java 1.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 19
java 1.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 20

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1-m.go 57ms 8.6ms 5.4MB 87ms 0ms go 1.19.1
go 1.go 272ms 0.3ms 68.7MB 247ms 10ms tinygo 0.25.0
java 1-m.java 737ms 38ms 107.3MB 1317ms 30ms openjdk 19
java 1-m.java 840ms 118ms 99.6MB 1487ms 40ms openjdk 20
java 1-m.java 958ms 20ms 311.7MB 1573ms 170ms openjdk/zgc 19