Javascript VS Go 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
javascript 1.js 1230ms 0.8ms 249.0MB 1550ms 60ms bun 0.1.13
go 1.go 2897ms 7.4ms 44.7MB 4130ms 57ms go 1.19.1
javascript 1.js 3018ms 733ms 359.6MB 2540ms 863ms node 18.9.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
javascript 1.js 113ms 2.0ms 104.4MB 103ms 13ms bun 0.1.13
javascript 1.js 197ms 0.8ms 84.0MB 183ms 23ms node 18.9.1
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
javascript 1.js 2328ms 34ms 80.3MB 2367ms 43ms node 18.9.1
javascript 1.js 3534ms 75ms 111.8MB 3537ms 30ms bun 0.1.13

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
javascript 1.js 224ms 1.7ms 61.7MB 203ms 17ms node 18.9.1
javascript 1.js 252ms 3.2ms 106.1MB 263ms 20ms bun 0.1.13
go 1.go 270ms 0.7ms 66.7MB 243ms 7ms tinygo 0.25.0

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
go 1.go 2.7ms 0.4ms 2.9MB 0ms 0ms go 1.19.1
javascript 1.js 15ms 0.4ms 50.6MB 0ms 0ms bun 0.1.13
javascript 1.js 55ms 0.4ms 41.9MB 38ms 4ms node 18.9.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
javascript 1.js 168ms 0.5ms 72.2MB 140ms 20ms node 18.9.1
go 1.go 171ms 2.1ms 20.2MB 157ms 7ms go 1.19.1
javascript 1.js 329ms 9.1ms 270.1MB 360ms 53ms bun 0.1.13

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
javascript 1.js 1085ms 1.5ms 284.9MB 1087ms 113ms node 18.9.1
javascript 1.js 2108ms 35ms 1235.4MB 1987ms 360ms bun 0.1.13

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
javascript 2.js 520ms 1.4ms 103.6MB 530ms 10ms bun 0.1.13
javascript 1.js 553ms 3.5ms 138.9MB 550ms 23ms bun 0.1.13
javascript 2.js 793ms 2.4ms 60.7MB 783ms 0ms node 18.9.1
javascript 1.js 1144ms 2.1ms 61.2MB 1123ms 10ms node 18.9.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
javascript 2.js 1498ms 8.1ms 103.7MB 1510ms 17ms bun 0.1.13
javascript 1.js 1577ms 10ms 166.8MB 1607ms 30ms bun 0.1.13
javascript 2.js 2217ms 24ms 62.5MB 2197ms 13ms node 18.9.1
javascript 1.js 3272ms 13ms 61.3MB 3257ms 3ms node 18.9.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
javascript 2.js 268ms 1.4ms 97.0MB 263ms 13ms bun 0.1.13
javascript 1.js 284ms 1.6ms 119.2MB 273ms 20ms bun 0.1.13
javascript 2.js 410ms 2.2ms 52.1MB 393ms 10ms node 18.9.1
javascript 1.js 445ms 1.5ms 49.3MB 423ms 10ms node 18.9.1

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 736ms 0.2ms 156.8MB 820ms 37ms bun 0.1.13
javascript 1.js 797ms 5.4ms 121.3MB 800ms 57ms node 18.9.1
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
javascript 1.js 166ms 0.8ms 100.0MB 157ms 13ms bun 0.1.13
javascript 1.js 247ms 3.3ms 88.7MB 233ms 23ms node 18.9.1
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
go 1.go 454ms 2.2ms 2.9MB 440ms 0ms go 1.19.1
javascript 6.js 626ms 6.2ms 46.9MB 610ms 7ms node 18.9.1
go 1.go 842ms 0.7ms 0.0MB 830ms 0ms tinygo 0.25.0
javascript 6.js 1062ms 1.4ms 63.3MB 1050ms 7ms bun 0.1.13

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
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
javascript 6.js 122ms 1.0ms 48.6MB 107ms 3ms node 18.9.1
javascript 6.js 125ms 1.6ms 65.2MB 113ms 7ms bun 0.1.13

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
javascript 1.js 2932ms 5.9ms 103.8MB 2957ms 23ms bun 0.1.13
javascript 1.js 3517ms 15ms 51.9MB 3513ms 17ms node 18.9.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
javascript 1.js 760ms 6.4ms 103.1MB 770ms 10ms bun 0.1.13
javascript 1.js 934ms 0.9ms 49.7MB 937ms 10ms node 18.9.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
javascript 1.js 3754ms 91ms 158.4MB 1553ms 353ms node 18.9.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
javascript 1.js 371ms 1.8ms 72.9MB 347ms 63ms node 18.9.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
javascript 3.js timeout 0.0ms 0.0MB 0ms 0ms node 18.9.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
javascript 3.js 1608ms 4.0ms 62.8MB 1583ms 20ms node 18.9.1

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 4-m.go 2499ms 19ms 5.5MB 4830ms 0ms go 1.19.1
javascript 6-m.js 2766ms 9.8ms 71.1MB 5217ms 23ms node 18.9.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
go 4-m.go 627ms 1.2ms 2.9MB 1193ms 0ms go 1.19.1
javascript 6-m.js 862ms 6.6ms 74.2MB 1517ms 37ms node 18.9.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
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
javascript 6.js 400ms 11ms 67.5MB 573ms 20ms node 18.9.1
go 1.go 646ms 0.6ms 2.0MB 640ms 0ms tinygo 0.25.0