Go VS C++ benchmarks

Current benchmark data was generated on Thu May 04 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz (Model 85)

* -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 3836ms 4.3ms 43.9MB 5480ms 57ms go 1.20.4
go 1.go 4878ms 33ms 51.4MB 4847ms 13ms tinygo 0.27.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 322ms 1.5ms 8.0MB 410ms 10ms go 1.20.4
go 1.go 462ms 3.0ms 6.6MB 450ms 0ms tinygo 0.27.0

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1-m.go 1290ms 175ms 13.5MB 2507ms 7ms go 1.20.4
go 1.go 3068ms 23ms 253.0MB 2967ms 83ms tinygo 0.27.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1-m.go 99ms 15ms 5.4MB 167ms 0ms go 1.20.4
go 1.go 430ms 2.8ms 66.6MB 400ms 10ms tinygo 0.27.0

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 167ms 4.3ms 8.3MB 147ms 3ms go 1.20.4

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 48ms 1.6ms 8.3MB 37ms 3ms go 1.20.4

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1-im.cpp 665ms 2.1ms 4.1MB 1287ms 0ms clang++ 14.0.0
cpp 1-im.cpp 689ms 1.7ms 1.4MB 1313ms 0ms g++ 12.2.0
go 3-m.go 1201ms 4.2ms 4.9MB 2313ms 3ms go 1.20.4
go 3.go 2771ms 0.9ms 50.1MB 2747ms 10ms tinygo 0.27.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1-im.cpp 64ms 0.9ms 3.9MB 107ms 0ms clang++ 14.0.0
cpp 1-im.cpp 67ms 0.7ms 1.3MB 110ms 0ms g++ 12.2.0
go 3.go 126ms 1.2ms 2.9MB 183ms 0ms go 1.20.4
go 3.go 377ms 1.0ms 48.6MB 357ms 7ms tinygo 0.27.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3-m.go 208ms 1.9ms 2.9MB 363ms 3ms go 1.20.4

Input: 250000

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

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 1.4ms 0.6ms 0.0MB 0ms 0ms tinygo 0.27.0
cpp 1.cpp 2.2ms 0.6ms 1.4MB 0ms 0ms clang++ 14.0.0
cpp 1.cpp 2.4ms 0.5ms 1.3MB 0ms 0ms g++ 12.2.0
go 1.go 2.9ms 0.9ms 2.9MB 0ms 0ms go 1.20.4

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1-http2.go 194ms 7.3ms 54.9MB 277ms 53ms go 1.20.4
go 2-m.go 673ms 30ms 157.5MB 667ms 437ms go 1.20.4
go 1-m.go 740ms 6.6ms 159.2MB 697ms 470ms go 1.20.4

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1-http2.go 46ms 1.2ms 23.3MB 50ms 3ms go 1.20.4
go 2.go 144ms 6.8ms 38.6MB 100ms 73ms go 1.20.4
go 1.go 145ms 10ms 35.9MB 103ms 77ms go 1.20.4

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 2-ffi.go 72ms 2.4ms 37.6MB 50ms 10ms go 1.20.4
go 1.go 181ms 5.4ms 18.3MB 157ms 7ms go 1.20.4

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 2-ffi.go 372ms 7.1ms 173.5MB 343ms 67ms go 1.20.4
go 1.go 1078ms 7.7ms 101.8MB 1057ms 50ms go 1.20.4

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 7-m.go 1373ms 9.8ms 42.6MB 2517ms 33ms go 1.20.4

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 7-m.go 229ms 6.1ms 22.4MB 347ms 33ms go 1.20.4

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 167ms 0.6ms 2.0MB 157ms 0ms tinygo 0.27.0
go 3.go 174ms 8.9ms 3.4MB 153ms 0ms go 1.20.4

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 491ms 1.8ms 3.4MB 480ms 0ms go 1.20.4
go 3.go 491ms 0.5ms 0.4MB 480ms 0ms tinygo 0.27.0

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.27.0
go 3.go 93ms 11ms 3.9MB 80ms 0ms go 1.20.4

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 3793ms 1.6ms 5.4MB 3780ms 0ms go 1.20.4
go 1.go timeout 0.0ms 5.4MB 4983ms 0ms tinygo 0.27.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 162ms 1.1ms 2.8MB 150ms 0ms go 1.20.4
go 1.go 304ms 0.2ms 0.0MB 290ms 0ms tinygo 0.27.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 2296ms 34ms 37.6MB 3233ms 50ms go 1.20.4
go 2.go 2560ms 11ms 39.8MB 3657ms 60ms go 1.20.4
go 1.go timeout 0.0ms 68.6MB 4967ms 13ms tinygo 0.27.0
go 2.go timeout 0.0ms 120.8MB 4960ms 20ms tinygo 0.27.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 480ms 9.0ms 12.1MB 653ms 13ms go 1.20.4
go 2.go 526ms 2.9ms 14.3MB 727ms 10ms go 1.20.4
go 1.go 787ms 2.6ms 23.1MB 763ms 3ms tinygo 0.27.0
go 2.go 1102ms 3.5ms 38.9MB 1080ms 7ms tinygo 0.27.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 184ms 1.2ms 1.3MB 170ms 0ms g++ 12.2.0
cpp 0-i.cpp 211ms 1.4ms 1.4MB 200ms 0ms clang++ 14.0.0
cpp 1.cpp 336ms 5.4ms 1.4MB 323ms 0ms clang++ 14.0.0
cpp 1.cpp 354ms 5.4ms 1.3MB 347ms 0ms g++ 12.2.0
go 1.go 459ms 12ms 2.0MB 447ms 0ms tinygo 0.27.0
go 1.go 494ms 2.3ms 2.9MB 480ms 0ms go 1.20.4

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 21ms 0.6ms 1.3MB 10ms 0ms g++ 12.2.0
cpp 0-i.cpp 25ms 1.1ms 1.4MB 13ms 0ms clang++ 14.0.0
cpp 1.cpp 37ms 0.2ms 1.3MB 30ms 0ms g++ 12.2.0
cpp 1.cpp 37ms 1.1ms 1.4MB 30ms 0ms clang++ 14.0.0
go 1.go 49ms 0.8ms 2.0MB 40ms 0ms tinygo 0.27.0
go 1.go 55ms 2.8ms 2.9MB 43ms 0ms go 1.20.4

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1.cpp 641ms 3.8ms 7.7MB 627ms 0ms g++ 12.2.0
cpp 1.cpp 676ms 0.5ms 7.8MB 667ms 0ms clang++ 14.0.0
go 2.go 744ms 0.8ms 17.4MB 730ms 0ms tinygo 0.27.0
go 2.go 925ms 3.2ms 21.8MB 907ms 7ms go 1.20.4
go 1.go 1116ms 85ms 72.5MB 1090ms 13ms go 1.20.4
go 1.go 1506ms 100ms 42.8MB 1480ms 7ms tinygo 0.27.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 133ms 2.2ms 21.5MB 110ms 10ms go 1.20.4
cpp 1.cpp 147ms 0.1ms 4.1MB 140ms 0ms g++ 12.2.0
cpp 1.cpp 153ms 0.7ms 4.0MB 147ms 0ms clang++ 14.0.0
go 1.go 155ms 9.7ms 13.6MB 140ms 0ms tinygo 0.27.0
go 2.go 177ms 1.6ms 5.1MB 160ms 0ms tinygo 0.27.0
go 2.go 213ms 2.3ms 7.5MB 203ms 0ms go 1.20.4

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 8.go 1356ms 6.1ms 8.6MB 1330ms 3ms go 1.20.4

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 8.go 328ms 1.2ms 8.5MB 310ms 0ms go 1.20.4

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 113.6MB 4960ms 93ms go 1.20.4
go 3.go timeout 0.0ms 104.0MB 4947ms 30ms tinygo 0.27.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 2459ms 2.8ms 18.8MB 2430ms 30ms go 1.20.4
go 3.go 3354ms 2.7ms 30.0MB 3330ms 7ms tinygo 0.27.0

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 0-ffi.go 150ms 1.4ms 9.6MB 137ms 3ms go 1.20.4

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 0-ffi.go 52ms 1.7ms 9.5MB 37ms 3ms go 1.20.4

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 8-m.cpp 889ms 0.7ms 3.4MB 1730ms 3ms clang++ 14.0.0
cpp 8-m.cpp 893ms 3.6ms 1.3MB 1737ms 0ms g++ 12.2.0
cpp 7-m.cpp 900ms 17ms 3.3MB 1743ms 0ms clang++ 14.0.0
cpp 7-m.cpp 903ms 21ms 1.3MB 1740ms 0ms g++ 12.2.0
cpp 6-im.cpp 1840ms 1.9ms 3.4MB 3607ms 3ms clang++ 14.0.0
cpp 6-im.cpp 1855ms 7.1ms 1.3MB 3617ms 0ms g++ 12.2.0
go 4-m.go 2226ms 29ms 4.9MB 4297ms 3ms go 1.20.4
go 1.go 4332ms 1.0ms 5.5MB 4323ms 0ms go 1.20.4
go 1.go timeout 0.0ms 0.4MB 4987ms 0ms tinygo 0.27.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 8-m.cpp 233ms 1.8ms 1.4MB 433ms 0ms g++ 12.2.0
cpp 8-m.cpp 233ms 2.9ms 3.3MB 430ms 0ms clang++ 14.0.0
cpp 7-m.cpp 234ms 2.0ms 1.3MB 433ms 0ms g++ 12.2.0
cpp 7-m.cpp 235ms 2.5ms 3.4MB 430ms 0ms clang++ 14.0.0
cpp 6-im.cpp 471ms 1.6ms 1.3MB 900ms 0ms g++ 12.2.0
cpp 6-im.cpp 471ms 1.1ms 3.4MB 897ms 0ms clang++ 14.0.0
go 4-m.go 566ms 1.0ms 2.9MB 1067ms 0ms go 1.20.4
go 1.go 1088ms 2.9ms 2.9MB 1077ms 0ms go 1.20.4
go 1.go timeout 0.0ms 0.0MB 4983ms 0ms tinygo 0.27.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 8-m.cpp 66ms 1.4ms 1.4MB 110ms 0ms g++ 12.2.0
cpp 7-m.cpp 66ms 1.2ms 2.5MB 107ms 0ms g++ 12.2.0
cpp 8-m.cpp 67ms 0.9ms 3.4MB 110ms 0ms clang++ 14.0.0
cpp 7-m.cpp 68ms 2.7ms 3.4MB 110ms 0ms clang++ 14.0.0
cpp 6-im.cpp 126ms 2.1ms 1.3MB 227ms 0ms g++ 12.2.0
cpp 6-im.cpp 127ms 0.9ms 3.5MB 230ms 0ms clang++ 14.0.0
go 4-m.go 151ms 0.7ms 2.9MB 263ms 0ms go 1.20.4
go 1.go 276ms 1.8ms 2.9MB 263ms 0ms go 1.20.4
go 1.go 1624ms 0.6ms 0.0MB 1610ms 0ms tinygo 0.27.0