Go VS Javascript benchmarks

Current benchmark data was generated on Sun Jan 29 2023, 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 1311ms 115ms 253.9MB 1557ms 67ms bun 0.5.1
go 1.go 3040ms 4.2ms 45.1MB 4367ms 53ms go 1.19.5
javascript 1.js 3548ms 72ms 239.0MB 2617ms 1197ms node 19.5.0
go 1.go 3913ms 11ms 39.6MB 3890ms 7ms tinygo 0.25.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 121ms 2.4ms 101.4MB 103ms 20ms bun 0.5.1
javascript 1.js 170ms 5.1ms 70.0MB 153ms 20ms node 19.5.0
go 1.go 274ms 7.4ms 8.2MB 337ms 7ms go 1.19.5
go 1.go 349ms 1.6ms 7.1MB 337ms 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 736ms 89ms 13.6MB 1430ms 0ms go 1.19.5
go 1.go 1700ms 13ms 257.5MB 1640ms 40ms tinygo 0.25.0
javascript 1.js 2318ms 32ms 81.3MB 2347ms 37ms node 19.5.0
javascript 1.js 3573ms 62ms 124.3MB 3573ms 30ms bun 0.5.1

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1-m.go 59ms 5.2ms 7.4MB 93ms 0ms go 1.19.5
javascript 1.js 250ms 11ms 62.5MB 210ms 13ms node 19.5.0
go 1.go 270ms 1.1ms 66.3MB 250ms 3ms tinygo 0.25.0
javascript 1.js 294ms 5.9ms 107.9MB 270ms 10ms bun 0.5.1

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 166ms 2.0ms 8.2MB 150ms 0ms go 1.19.5
javascript 1.js 395ms 1.0ms 98.1MB 377ms 10ms bun 0.5.1
javascript 1.js 404ms 1.7ms 61.3MB 407ms 17ms node 19.5.0

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 49ms 1.7ms 8.2MB 37ms 0ms go 1.19.5
javascript 1.js 188ms 0.3ms 52.6MB 193ms 10ms node 19.5.0
javascript 1.js 415ms 0.9ms 86.8MB 393ms 17ms bun 0.5.1

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3-m.go 1395ms 1.7ms 5.0MB 2700ms 7ms go 1.19.5
go 3.go 2942ms 4.0ms 49.9MB 2917ms 3ms tinygo 0.25.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3-m.go 144ms 2.6ms 5.0MB 220ms 0ms go 1.19.5
go 3.go 312ms 0.4ms 48.4MB 297ms 3ms 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 252ms 2.9ms 4.9MB 460ms 0ms go 1.19.5

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 33ms 2.2ms 2.9MB 40ms 0ms go 1.19.5

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 1.4ms 0.5ms 0.1MB 0ms 0ms tinygo 0.25.0
go 1.go 2.6ms 0.4ms 2.9MB 0ms 0ms go 1.19.5
javascript 1.js 15ms 1.1ms 55.5MB 0ms 0ms bun 0.5.1
javascript 1.js 43ms 0.7ms 43.1MB 30ms 2ms node 19.5.0

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.bun.js 134ms 11ms 92.4MB 80ms 50ms bun 0.5.1
go 1-http2.go 162ms 4.1ms 57.5MB 227ms 53ms go 1.19.5
go 1-m.go 583ms 26ms 174.0MB 557ms 353ms go 1.19.5
go 2-m.go 638ms 88ms 180.1MB 650ms 383ms go 1.19.5
javascript 1.js 3863ms 30ms 155.6MB 1723ms 377ms node 19.5.0

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1-http2.go 40ms 1.2ms 24.8MB 37ms 13ms go 1.19.5
javascript 1.bun.js 92ms 8.9ms 70.9MB 20ms 27ms bun 0.5.1
go 2.go 102ms 33ms 37.4MB 57ms 47ms go 1.19.5
go 1.go 130ms 16ms 36.9MB 90ms 53ms go 1.19.5
javascript 1.js 368ms 5.6ms 71.7MB 370ms 57ms node 19.5.0

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 2-ffi.go 73ms 2.3ms 41.9MB 57ms 10ms go 1.19.5
javascript 1.js 131ms 0.9ms 89.9MB 113ms 7ms bun 0.5.1
javascript 1.js 167ms 3.7ms 74.1MB 143ms 17ms node 19.5.0
go 1.go 171ms 4.2ms 20.2MB 157ms 7ms go 1.19.5

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 2-ffi.go 420ms 3.3ms 188.8MB 380ms 123ms go 1.19.5
javascript 1.js 724ms 2.7ms 262.1MB 703ms 47ms bun 0.5.1
javascript 1.js 1074ms 4.5ms 282.1MB 1017ms 117ms node 19.5.0
go 1.go 1078ms 2.7ms 102.5MB 1053ms 57ms go 1.19.5

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 7-m.go 1498ms 12ms 42.0MB 2803ms 20ms go 1.19.5

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 7-m.go 233ms 8.4ms 24.0MB 363ms 17ms go 1.19.5

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 165ms 0.5ms 0.3MB 160ms 0ms tinygo 0.25.0
go 3.go 175ms 1.8ms 2.9MB 160ms 0ms go 1.19.5
javascript 2.js 379ms 5.0ms 54.5MB 367ms 3ms node 19.5.0
javascript 1.js 569ms 2.9ms 146.2MB 560ms 20ms bun 0.5.1
javascript 2.js 794ms 2.8ms 109.1MB 793ms 23ms bun 0.5.1
javascript 1.js 1035ms 3.1ms 62.2MB 1017ms 10ms node 19.5.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 490ms 0.1ms 0.3MB 480ms 0ms tinygo 0.25.0
go 3.go 518ms 3.2ms 2.9MB 503ms 0ms go 1.19.5
javascript 2.js 1011ms 4.7ms 62.0MB 997ms 10ms node 19.5.0
javascript 1.js 1591ms 8.0ms 169.9MB 1617ms 17ms bun 0.5.1
javascript 2.js 2293ms 4.9ms 121.0MB 2300ms 13ms bun 0.5.1
javascript 1.js 2977ms 2.8ms 61.6MB 2947ms 20ms node 19.5.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 81ms 0.2ms 0.0MB 70ms 0ms tinygo 0.25.0
go 3.go 94ms 2.8ms 3.9MB 87ms 0ms go 1.19.5
javascript 2.js 207ms 4.0ms 48.5MB 197ms 3ms node 19.5.0
javascript 1.js 291ms 8.0ms 117.4MB 280ms 17ms bun 0.5.1
javascript 1.js 376ms 1.8ms 49.8MB 363ms 7ms node 19.5.0
javascript 2.js 428ms 4.2ms 100.7MB 437ms 10ms bun 0.5.1

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 4384ms 9.5ms 5.4MB 4373ms 0ms go 1.19.5
go 1.go timeout 0.0ms 4.9MB 4990ms 0ms tinygo 0.25.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 185ms 2.5ms 2.9MB 170ms 0ms go 1.19.5
go 1.go 245ms 0.6ms 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
javascript 1.js 742ms 11ms 158.6MB 820ms 33ms bun 0.5.1
javascript 1.js 773ms 6.5ms 122.2MB 777ms 57ms node 19.5.0
go 1.go 1997ms 15ms 40.3MB 2810ms 27ms go 1.19.5
go 2.go 2327ms 59ms 41.8MB 3230ms 67ms go 1.19.5
go 1.go 3809ms 7.3ms 213.3MB 3757ms 40ms tinygo 0.25.0
go 2.go timeout 0.0ms 90.8MB 4977ms 10ms tinygo 0.25.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 172ms 1.9ms 108.9MB 163ms 13ms bun 0.5.1
javascript 1.js 228ms 7.2ms 90.2MB 213ms 33ms node 19.5.0
go 1.go 424ms 6.7ms 12.4MB 573ms 10ms go 1.19.5
go 2.go 492ms 6.9ms 14.7MB 657ms 17ms go 1.19.5
go 1.go 656ms 1.2ms 51.1MB 637ms 3ms tinygo 0.25.0
go 2.go 1264ms 2.6ms 38.6MB 1247ms 3ms tinygo 0.25.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 456ms 1.4ms 2.9MB 440ms 0ms go 1.19.5
javascript 6.js 603ms 4.1ms 47.2MB 590ms 7ms node 19.5.0
go 1.go 843ms 1.0ms 0.0MB 830ms 0ms tinygo 0.25.0
javascript 6.js 1010ms 1.0ms 63.9MB 1000ms 7ms bun 0.5.1

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 51ms 3.8ms 2.9MB 40ms 0ms go 1.19.5
go 1.go 86ms 0.6ms 0.0MB 80ms 0ms tinygo 0.25.0
javascript 6.js 106ms 3.3ms 47.3MB 97ms 3ms node 19.5.0
javascript 6.js 122ms 2.4ms 70.0MB 120ms 3ms bun 0.5.1

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 2.go 623ms 4.5ms 17.6MB 613ms 0ms tinygo 0.25.0
go 1.go 669ms 21ms 75.2MB 640ms 13ms go 1.19.5
go 1.go 727ms 17ms 43.1MB 707ms 3ms tinygo 0.25.0
go 2.go 904ms 0.7ms 20.0MB 883ms 7ms go 1.19.5

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 121ms 2.3ms 22.1MB 107ms 3ms go 1.19.5
go 1.go 131ms 0.7ms 13.4MB 120ms 0ms tinygo 0.25.0
go 2.go 146ms 0.4ms 5.6MB 140ms 0ms tinygo 0.25.0
go 2.go 216ms 2.8ms 9.1MB 203ms 3ms go 1.19.5

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 8.go 1390ms 1.4ms 8.5MB 1367ms 7ms go 1.19.5
javascript 3.js timeout 0.0ms 79.1MB 4987ms 13ms node 19.5.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 8.go 335ms 5.3ms 8.4MB 317ms 0ms go 1.19.5
javascript 3.js 1552ms 3.1ms 62.9MB 1550ms 7ms node 19.5.0

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 110.9MB 4963ms 83ms go 1.19.5
go 3.go timeout 0.0ms 120.9MB 4960ms 30ms tinygo 0.25.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 2536ms 6.2ms 17.8MB 2510ms 27ms go 1.19.5
go 3.go timeout 0.0ms 30.2MB 4987ms 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 173ms 4.1ms 10.1MB 160ms 3ms go 1.19.5
javascript 1.js 3041ms 28ms 103.8MB 3063ms 20ms bun 0.5.1
javascript 1.js 3314ms 17ms 51.9MB 3310ms 13ms node 19.5.0

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 0-ffi.go 57ms 1.2ms 9.6MB 43ms 0ms go 1.19.5
javascript 1.js 784ms 3.2ms 104.0MB 787ms 13ms bun 0.5.1
javascript 1.js 875ms 5.7ms 50.0MB 877ms 0ms node 19.5.0

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 4-m.go 2502ms 32ms 6.9MB 4830ms 3ms go 1.19.5
javascript 6-m.js 2755ms 8.6ms 69.5MB 5193ms 17ms node 19.5.0
go 1.go 4961ms 8.6ms 5.5MB 4950ms 0ms go 1.19.5
go 1.go timeout 0.0ms 0.4MB 4987ms 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 632ms 4.9ms 2.9MB 1197ms 0ms go 1.19.5
javascript 6-m.js 847ms 18ms 69.1MB 1480ms 17ms node 19.5.0
go 1.go 1248ms 4.9ms 2.9MB 1230ms 0ms go 1.19.5
go 1.go 2584ms 6.9ms 0.0MB 2567ms 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 168ms 1.6ms 4.9MB 293ms 0ms go 1.19.5
go 1.go 316ms 2.0ms 4.9MB 303ms 0ms go 1.19.5
javascript 6.js 388ms 18ms 70.3MB 527ms 20ms node 19.5.0
go 1.go 645ms 0.1ms 0.0MB 633ms 0ms tinygo 0.25.0