OCaml VS Javascript 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
javascript 1.js 1519ms 9.2ms 229.7MB 1900ms 70ms bun 0.5.9
javascript 1.js 3652ms 865ms 319.8MB 2967ms 1180ms node 20.0.0
ocaml 1.ml timeout 0.0ms 145.4MB 4903ms 73ms ocaml 5.0.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 144ms 1.8ms 102.1MB 123ms 23ms bun 0.5.9
javascript 1.js 208ms 4.2ms 72.4MB 190ms 23ms node 20.0.0
ocaml 1.ml 359ms 8.8ms 22.9MB 337ms 7ms ocaml 5.0.0

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 3637ms 2.2ms 2.7MB 3620ms 0ms ocaml 5.0.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 303ms 0.9ms 2.8MB 290ms 0ms ocaml 5.0.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 6.ml 387ms 4.7ms 22.7MB 360ms 7ms ocaml 5.0.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 6.ml 42ms 0.4ms 4.9MB 30ms 0ms ocaml 5.0.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 2.9ms 0.5ms 2.7MB 0ms 0ms ocaml 5.0.0
javascript 1.js 19ms 0.8ms 52.7MB 0ms 10ms bun 0.5.9
javascript 1.js 46ms 0.7ms 45.0MB 28ms 8ms node 20.0.0

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 250ms 4.9ms 6.7MB 240ms 0ms ocaml 5.0.0
javascript 2.js 355ms 4.3ms 57.2MB 340ms 10ms node 20.0.0
javascript 1.js 651ms 3.0ms 143.4MB 637ms 43ms bun 0.5.9
javascript 2.js 683ms 4.4ms 112.9MB 670ms 33ms bun 0.5.9
javascript 1.js 701ms 2.2ms 55.3MB 680ms 10ms node 20.0.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 727ms 1.6ms 6.7MB 717ms 0ms ocaml 5.0.0
javascript 2.js 944ms 7.0ms 63.9MB 920ms 17ms node 20.0.0
javascript 1.js 1837ms 5.4ms 172.3MB 1850ms 63ms bun 0.5.9
javascript 2.js 1937ms 15ms 118.5MB 1943ms 20ms bun 0.5.9
javascript 1.js 1996ms 11ms 61.7MB 1977ms 10ms node 20.0.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 110ms 0.4ms 6.0MB 93ms 0ms ocaml 5.0.0
javascript 2.js 194ms 0.4ms 50.9MB 180ms 10ms node 20.0.0
javascript 1.js 239ms 0.9ms 52.0MB 227ms 7ms node 20.0.0
javascript 1.js 323ms 1.1ms 118.3MB 320ms 20ms bun 0.5.9
javascript 2.js 376ms 5.4ms 109.9MB 370ms 27ms bun 0.5.9

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 933ms 8.0ms 155.5MB 1027ms 43ms bun 0.5.9
javascript 1.js 1028ms 14ms 124.8MB 1050ms 63ms node 20.0.0
ocaml 1.ml 1931ms 14ms 69.1MB 1880ms 30ms ocaml 5.0.0
ocaml 2.ml 3617ms 28ms 74.2MB 3557ms 43ms ocaml 5.0.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 211ms 8.9ms 107.1MB 187ms 27ms bun 0.5.9
javascript 1.js 275ms 8.2ms 92.5MB 253ms 37ms node 20.0.0
ocaml 1.ml 275ms 3.8ms 25.6MB 253ms 3ms ocaml 5.0.0
ocaml 2.ml 629ms 19ms 30.1MB 610ms 7ms ocaml 5.0.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 546ms 8.2ms 2.9MB 533ms 0ms ocaml 5.0.0
javascript 6.js 677ms 18ms 49.7MB 663ms 7ms node 20.0.0
javascript 6.js 1043ms 6.1ms 70.1MB 1033ms 7ms bun 0.5.9

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 59ms 0.7ms 2.8MB 50ms 0ms ocaml 5.0.0
javascript 6.js 117ms 2.2ms 49.8MB 100ms 3ms node 20.0.0
javascript 6.js 128ms 0.3ms 70.4MB 113ms 10ms bun 0.5.9

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 2718ms 31ms 19.1MB 2703ms 0ms ocaml 5.0.0
ocaml 1.ml 3571ms 30ms 550.6MB 3400ms 157ms ocaml 5.0.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 640ms 4.4ms 9.3MB 627ms 0ms ocaml 5.0.0
ocaml 1.ml 763ms 24ms 140.2MB 713ms 30ms ocaml 5.0.0

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml timeout 0.0ms 181.9MB 4887ms 90ms ocaml 5.0.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 715ms 2.6ms 52.5MB 673ms 27ms ocaml 5.0.0

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 6-m.js 2786ms 13ms 72.0MB 5217ms 23ms node 20.0.0
ocaml 2.ml timeout 0.0ms 4.2MB 4987ms 0ms ocaml 5.0.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 6-m.js 847ms 3.0ms 73.2MB 1490ms 33ms node 20.0.0
ocaml 2.ml 1540ms 14ms 3.5MB 1527ms 0ms ocaml 5.0.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 394ms 0.4ms 3.3MB 380ms 0ms ocaml 5.0.0
javascript 6.js 421ms 11ms 69.9MB 547ms 27ms node 20.0.0