Go VS C++ benchmarks

Current benchmark data was generated on Wed Sep 28 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
go 1.go 2897ms 7.4ms 44.7MB 4130ms 57ms go 1.19.1
go 1.go 3962ms 29ms 39.1MB 3947ms 0ms tinygo 0.25.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 257ms 2.9ms 8.2MB 333ms 3ms go 1.19.1
go 1.go 303ms 0.3ms 6.0MB 290ms 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 741ms 41ms 13.6MB 1443ms 0ms go 1.19.1
go 1.go 1717ms 3.5ms 253.7MB 1650ms 50ms tinygo 0.25.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1-m.go 56ms 5.7ms 5.4MB 93ms 0ms go 1.19.1
go 1.go 270ms 0.7ms 66.7MB 243ms 7ms tinygo 0.25.0

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 169ms 2.8ms 8.5MB 153ms 3ms go 1.19.1

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 49ms 2.5ms 8.2MB 40ms 0ms go 1.19.1

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1-im.cpp 752ms 3.8ms 1.0MB 1450ms 0ms g++ 12.2.0
cpp 1-im.cpp 769ms 6.3ms 3.6MB 1493ms 0ms clang++ 11.0.0
go 3-m.go 1448ms 9.9ms 3.0MB 2803ms 0ms go 1.19.1
go 3.go 2930ms 1.7ms 49.1MB 2910ms 10ms tinygo 0.25.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1-im.cpp 72ms 0.8ms 1.0MB 120ms 0ms g++ 12.2.0
cpp 1-im.cpp 73ms 0.6ms 3.6MB 120ms 0ms clang++ 11.0.0
go 3-m.go 144ms 1.8ms 5.0MB 223ms 0ms go 1.19.1
go 3.go 309ms 0.7ms 50.1MB 297ms 0ms tinygo 0.25.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3-m.go 238ms 0.4ms 2.9MB 440ms 0ms go 1.19.1

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 30ms 0.2ms 2.9MB 40ms 0ms go 1.19.1

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 1.8ms 0.7ms 2.0MB 0ms 0ms tinygo 0.25.0
cpp 1.cpp 2.2ms 0.9ms 1.1MB 0ms 0ms clang++ 11.0.0
cpp 1.cpp 2.5ms 1.1ms 1.0MB 0ms 0ms g++ 12.2.0
go 1.go 2.7ms 0.4ms 2.9MB 0ms 0ms go 1.19.1

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1-http2.go 162ms 5.8ms 58.4MB 243ms 37ms go 1.19.1
go 1-m.go 567ms 30ms 179.2MB 543ms 323ms go 1.19.1
go 2-m.go 585ms 63ms 176.1MB 580ms 343ms go 1.19.1

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1-http2.go 40ms 3.1ms 22.7MB 40ms 10ms go 1.19.1
go 2.go 113ms 1.2ms 39.1MB 80ms 43ms go 1.19.1
go 1.go 119ms 8.4ms 38.0MB 77ms 50ms go 1.19.1

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 2-ffi.go 71ms 0.4ms 39.5MB 53ms 13ms go 1.19.1
go 1.go 171ms 2.1ms 20.2MB 157ms 7ms go 1.19.1

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 2-ffi.go 396ms 8.4ms 187.8MB 373ms 90ms go 1.19.1
go 1.go 1039ms 5.9ms 106.0MB 1003ms 63ms go 1.19.1

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 7-m.go 1510ms 5.2ms 41.1MB 2797ms 37ms go 1.19.1

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 7-m.go 226ms 3.0ms 22.4MB 360ms 13ms go 1.19.1

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 166ms 0.4ms 0.3MB 160ms 0ms tinygo 0.25.0
go 3.go 173ms 1.4ms 2.8MB 160ms 0ms go 1.19.1

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 491ms 0.3ms 0.3MB 480ms 0ms tinygo 0.25.0
go 3.go 514ms 3.1ms 3.4MB 500ms 0ms go 1.19.1

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 81ms 0.5ms 0.0MB 70ms 0ms tinygo 0.25.0
go 3.go 93ms 2.3ms 5.6MB 83ms 0ms go 1.19.1

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 4110ms 15ms 6.9MB 4093ms 0ms go 1.19.1
go 1.go timeout 0.0ms 0.0MB 0ms 0ms tinygo 0.25.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 171ms 0.3ms 2.8MB 160ms 0ms go 1.19.1
go 1.go 245ms 0.3ms 0.0MB 233ms 0ms tinygo 0.25.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 1891ms 8.9ms 38.2MB 2680ms 17ms go 1.19.1
go 2.go 2233ms 22ms 52.9MB 3143ms 57ms go 1.19.1
go 1.go 3053ms 3.0ms 159.8MB 3003ms 37ms 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
go 1.go 409ms 5.1ms 12.5MB 563ms 10ms go 1.19.1
go 2.go 477ms 1.5ms 14.3MB 647ms 20ms go 1.19.1
go 1.go 800ms 6.4ms 39.1MB 783ms 3ms tinygo 0.25.0
go 2.go 1329ms 3.7ms 52.1MB 1313ms 0ms tinygo 0.25.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 225ms 0.2ms 0.9MB 210ms 0ms g++ 12.2.0
cpp 0-i.cpp 257ms 0.5ms 1.1MB 243ms 0ms clang++ 11.0.0
cpp 1.cpp 339ms 1.0ms 0.9MB 330ms 0ms g++ 12.2.0
cpp 1.cpp 384ms 0.4ms 1.1MB 373ms 0ms clang++ 11.0.0
go 1.go 454ms 2.2ms 2.9MB 440ms 0ms go 1.19.1
go 1.go 842ms 0.7ms 0.0MB 830ms 0ms tinygo 0.25.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 25ms 0.3ms 1.0MB 20ms 0ms g++ 12.2.0
cpp 0-i.cpp 28ms 0.3ms 1.1MB 20ms 0ms clang++ 11.0.0
cpp 1.cpp 37ms 0.2ms 1.0MB 30ms 0ms g++ 12.2.0
cpp 1.cpp 42ms 0.7ms 1.1MB 30ms 0ms clang++ 11.0.0
go 1.go 49ms 1.8ms 2.9MB 37ms 0ms go 1.19.1
go 1.go 86ms 0.5ms 0.0MB 80ms 0ms tinygo 0.25.0

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1.cpp 415ms 6.4ms 7.5MB 403ms 0ms clang++ 11.0.0
go 1.go 574ms 29ms 75.2MB 540ms 13ms go 1.19.1
go 2.go 632ms 2.0ms 17.4MB 613ms 0ms tinygo 0.25.0
cpp 1.cpp 648ms 9.1ms 7.7MB 633ms 0ms g++ 12.2.0
go 1.go 749ms 39ms 43.8MB 727ms 7ms tinygo 0.25.0
go 2.go 915ms 14ms 20.0MB 897ms 10ms go 1.19.1

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1.cpp 94ms 0.8ms 3.7MB 87ms 0ms clang++ 11.0.0
go 1.go 133ms 1.5ms 13.9MB 120ms 0ms tinygo 0.25.0
go 1.go 134ms 8.0ms 21.9MB 120ms 0ms go 1.19.1
go 2.go 146ms 0.6ms 5.4MB 133ms 0ms tinygo 0.25.0
cpp 1.cpp 154ms 0.7ms 4.0MB 140ms 0ms g++ 12.2.0
go 2.go 218ms 2.3ms 8.1MB 200ms 3ms go 1.19.1

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 8.go 1425ms 2.8ms 8.4MB 1393ms 10ms go 1.19.1

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 8.go 338ms 1.2ms 8.4MB 323ms 0ms go 1.19.1

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

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 2475ms 29ms 18.2MB 2460ms 20ms go 1.19.1
go 3.go timeout 0.0ms 0.0MB 0ms 0ms tinygo 0.25.0

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 0-ffi.go 170ms 1.5ms 8.1MB 160ms 3ms go 1.19.1

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 0-ffi.go 54ms 0.8ms 9.5MB 47ms 0ms go 1.19.1

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 8-m.cpp 1060ms 1.0ms 3.1MB 2073ms 0ms clang++ 11.0.0
cpp 7-m.cpp 1061ms 2.4ms 3.2MB 2073ms 0ms clang++ 11.0.0
cpp 8-m.cpp 1062ms 1.1ms 0.9MB 2080ms 0ms g++ 12.2.0
cpp 7-m.cpp 1065ms 1.7ms 1.0MB 2083ms 0ms g++ 12.2.0
cpp 6-im.cpp 2234ms 1.6ms 1.0MB 4400ms 0ms g++ 12.2.0
cpp 6-im.cpp 2245ms 15ms 3.2MB 4407ms 0ms clang++ 11.0.0
go 4-m.go 2499ms 19ms 5.5MB 4830ms 0ms go 1.19.1
go 1.go 4890ms 3.2ms 5.5MB 4880ms 0ms go 1.19.1
go 1.go timeout 0.0ms 0.0MB 0ms 0ms tinygo 0.25.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 8-m.cpp 274ms 0.2ms 1.0MB 520ms 0ms g++ 12.2.0
cpp 8-m.cpp 275ms 0.2ms 3.2MB 517ms 0ms clang++ 11.0.0
cpp 7-m.cpp 276ms 1.7ms 3.2MB 517ms 0ms clang++ 11.0.0
cpp 7-m.cpp 277ms 2.5ms 1.0MB 520ms 0ms g++ 12.2.0
cpp 6-im.cpp 568ms 2.1ms 0.9MB 1100ms 0ms g++ 12.2.0
cpp 6-im.cpp 568ms 1.5ms 3.2MB 1097ms 0ms clang++ 11.0.0
go 4-m.go 627ms 1.2ms 2.9MB 1193ms 0ms go 1.19.1
go 1.go 1227ms 6.7ms 2.9MB 1213ms 0ms go 1.19.1
go 1.go 2576ms 1.3ms 0.0MB 2563ms 0ms tinygo 0.25.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 8-m.cpp 76ms 1.8ms 3.2MB 127ms 0ms clang++ 11.0.0
cpp 7-m.cpp 76ms 1.1ms 3.2MB 127ms 0ms clang++ 11.0.0
cpp 8-m.cpp 77ms 0.8ms 1.0MB 130ms 0ms g++ 12.2.0
cpp 7-m.cpp 77ms 0.6ms 1.0MB 130ms 0ms g++ 12.2.0
cpp 6-im.cpp 151ms 0.1ms 1.0MB 277ms 0ms g++ 12.2.0
cpp 6-im.cpp 151ms 2.2ms 3.2MB 273ms 0ms clang++ 11.0.0
go 4-m.go 165ms 0.6ms 2.9MB 297ms 0ms go 1.19.1
go 1.go 310ms 1.4ms 2.9MB 300ms 0ms go 1.19.1
go 1.go 646ms 0.6ms 2.0MB 640ms 0ms tinygo 0.25.0