Javascript VS Java benchmarks

Current benchmark data was generated on Thu Sep 22 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
java 2.java 664ms 1.0ms 413.9MB 690ms 83ms openjdk 20
java 2.java 690ms 43ms 602.5MB 673ms 120ms openjdk 19
java 2.java 744ms 45ms 680.0MB 807ms 163ms graal/jvm 17.0.4
java 2.java 1277ms 28ms 1069.2MB 903ms 583ms openjdk/zgc 19
javascript 1.js 1299ms 21ms 243.8MB 1663ms 47ms bun 0.1.13
javascript 1.js 3480ms 97ms 266.7MB 2650ms 1267ms node 18.9.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 117ms 2.5ms 102.8MB 100ms 13ms bun 0.1.13
java 2.java 164ms 6.4ms 109.4MB 170ms 23ms openjdk 19
java 2.java 174ms 14ms 111.4MB 163ms 37ms openjdk 20
java 2-m.java 182ms 6.2ms 168.4MB 240ms 40ms graal/jvm 17.0.4
javascript 1.js 204ms 1.9ms 84.2MB 180ms 30ms node 18.9.0
java 2.java 300ms 5.7ms 243.7MB 187ms 153ms openjdk/zgc 19

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 2393ms 45ms 80.6MB 2417ms 43ms node 18.9.0
javascript 1.js 3485ms 11ms 115.3MB 3500ms 40ms bun 0.1.13
java 1-m.java 4259ms 124ms 932.0MB 7657ms 480ms openjdk/zgc 19
java 1.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 19
java 1.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 20

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 250ms 5.2ms 105.1MB 270ms 13ms bun 0.1.13
javascript 1.js 255ms 1.2ms 61.8MB 203ms 20ms node 18.9.0
java 1-m.java 737ms 38ms 107.3MB 1317ms 30ms openjdk 19
java 1-m.java 840ms 118ms 99.6MB 1487ms 40ms openjdk 20
java 1-m.java 958ms 20ms 311.7MB 1573ms 170ms openjdk/zgc 19

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 15ms 0.4ms 50.6MB 0ms 0ms bun 0.1.13
javascript 1.js 56ms 0.9ms 41.9MB 40ms 2ms node 18.9.0
java 1.java 70ms 3.1ms 63.4MB 70ms 10ms graal/jvm 17.0.4
java 1.java 78ms 5.0ms 42.7MB 78ms 6ms openjdk 20
java 1.java 82ms 3.6ms 40.8MB 78ms 8ms openjdk 19
java 1.java 119ms 4.8ms 39.9MB 78ms 52ms openjdk/zgc 19

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 171ms 1.1ms 73.1MB 157ms 10ms node 18.9.0
javascript 1.js 332ms 7.1ms 269.5MB 380ms 37ms bun 0.1.13

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 1090ms 6.5ms 285.2MB 1110ms 90ms node 18.9.0
javascript 1.js 2260ms 47ms 1178.2MB 2033ms 430ms bun 0.1.13

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 2.js 522ms 1.6ms 98.5MB 530ms 7ms bun 0.1.13
javascript 1.js 570ms 19ms 145.1MB 560ms 23ms bun 0.1.13
javascript 2.js 790ms 7.0ms 60.5MB 777ms 10ms node 18.9.0
javascript 1.js 1148ms 2.3ms 61.2MB 1127ms 13ms node 18.9.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 2.js 1513ms 13ms 109.6MB 1523ms 13ms bun 0.1.13
javascript 1.js 1584ms 5.5ms 163.5MB 1593ms 43ms bun 0.1.13
javascript 2.js 2188ms 20ms 62.5MB 2173ms 13ms node 18.9.0
javascript 1.js 3289ms 12ms 61.2MB 3270ms 13ms node 18.9.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 2.js 273ms 4.1ms 105.2MB 267ms 17ms bun 0.1.13
javascript 1.js 319ms 4.2ms 114.2MB 277ms 20ms bun 0.1.13
javascript 2.js 413ms 1.2ms 50.4MB 393ms 13ms node 18.9.0
javascript 1.js 446ms 0.3ms 49.4MB 423ms 10ms node 18.9.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 495ms 5.0ms 291.5MB 513ms 73ms openjdk 20
java 1.java 512ms 13ms 367.3MB 520ms 83ms openjdk 19
java 1.java 549ms 9.4ms 361.3MB 697ms 87ms graal/jvm 17.0.4
javascript 1.js 766ms 6.7ms 148.8MB 853ms 37ms bun 0.1.13
javascript 1.js 822ms 2.1ms 121.4MB 850ms 37ms node 18.9.0
java 1.java 932ms 20ms 758.5MB 643ms 430ms openjdk/zgc 19

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 168ms 1.5ms 100.1MB 157ms 13ms bun 0.1.13
java 1.java 219ms 2.1ms 173.3MB 243ms 37ms openjdk 19
java 1.java 223ms 6.1ms 174.3MB 237ms 43ms openjdk 20
javascript 1.js 251ms 1.6ms 88.8MB 237ms 23ms node 18.9.0
java 1-m.java 267ms 8.9ms 245.9MB 380ms 60ms graal/jvm 17.0.4
java 1.java 433ms 6.0ms 353.0MB 260ms 230ms openjdk/zgc 19

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 539ms 2.8ms 86.1MB 583ms 20ms graal/jvm 17.0.4
java 1.java 558ms 2.9ms 44.4MB 563ms 23ms openjdk 20
java 1.java 558ms 2.6ms 42.4MB 577ms 13ms openjdk 19
java 1.java 614ms 4.4ms 42.3MB 590ms 57ms openjdk/zgc 19
javascript 6.js 627ms 5.8ms 46.8MB 613ms 7ms node 18.9.0
javascript 6.js 1046ms 25ms 69.7MB 1037ms 3ms bun 0.1.13
java 2.java 1887ms 33ms 538.3MB 1923ms 107ms openjdk 19
java 2.java 1923ms 9.6ms 563.7MB 1950ms 127ms openjdk 20
java 2.java 2582ms 4.7ms 1219.4MB 2027ms 753ms openjdk/zgc 19

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 6.js 123ms 0.9ms 46.9MB 100ms 10ms node 18.9.0
javascript 6.js 125ms 4.6ms 67.4MB 117ms 3ms bun 0.1.13
java 1.java 142ms 3.9ms 42.7MB 157ms 17ms openjdk 20
java 1.java 144ms 1.6ms 86.4MB 190ms 20ms graal/jvm 17.0.4
java 1.java 146ms 5.8ms 42.7MB 167ms 10ms openjdk 19
java 1.java 190ms 3.5ms 42.2MB 160ms 57ms openjdk/zgc 19
java 2.java 414ms 4.9ms 363.3MB 493ms 70ms openjdk 20
java 2.java 417ms 2.1ms 355.0MB 483ms 73ms openjdk 19
java 2.java 676ms 0.7ms 455.4MB 547ms 290ms openjdk/zgc 19

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 2952ms 5.6ms 100.1MB 2980ms 20ms bun 0.1.13
javascript 1.js 3484ms 5.4ms 52.0MB 3490ms 13ms node 18.9.0

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 759ms 1.2ms 104.8MB 770ms 13ms bun 0.1.13
javascript 1.js 924ms 1.8ms 49.9MB 927ms 7ms node 18.9.0

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js timeout 0.0ms 0.0MB 0ms 0ms node 18.9.0

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 373ms 6.6ms 72.6MB 337ms 73ms node 18.9.0

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 4981ms 1.4ms 374.1MB 5360ms 117ms graal/jvm 17.0.4
java 1.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 19
java 1.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 20
java 1.java timeout 0.0ms 0.0MB 0ms 0ms openjdk/zgc 19
javascript 3.js timeout 0.0ms 0.0MB 0ms 0ms node 18.9.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 1362ms 9.0ms 390.5MB 1710ms 97ms graal/jvm 17.0.4
java 1.java 1411ms 34ms 288.1MB 1777ms 70ms openjdk 19
java 1.java 1453ms 6.4ms 302.3MB 1863ms 57ms openjdk 20
javascript 3.js 1611ms 2.4ms 62.8MB 1600ms 13ms node 18.9.0
java 1.java 1946ms 8.4ms 924.1MB 1807ms 637ms openjdk/zgc 19

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 6-m.js 2762ms 13ms 70.4MB 5210ms 17ms node 18.9.0
java 2-m.java 4306ms 8.2ms 104.9MB 8330ms 30ms graal/jvm 17.0.4
java 2.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 19
java 2.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 20
java 2.java timeout 0.0ms 0.0MB 0ms 0ms openjdk/zgc 19

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 6-m.js 864ms 2.9ms 70.0MB 1537ms 23ms node 18.9.0
java 2-m.java 1270ms 5.6ms 108.9MB 2323ms 37ms graal/jvm 17.0.4
java 2-m.java 1647ms 83ms 44.4MB 3100ms 20ms openjdk 19
java 2-m.java 1733ms 180ms 44.2MB 3290ms 17ms openjdk 20
java 2-m.java 1755ms 197ms 42.6MB 3250ms 57ms openjdk/zgc 19

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 6-m.js 404ms 4.4ms 67.7MB 577ms 30ms node 18.9.0
java 2-m.java 446ms 11ms 98.3MB 743ms 40ms graal/jvm 17.0.4
java 2-m.java 563ms 42ms 44.2MB 1017ms 10ms openjdk 20
java 2-m.java 582ms 12ms 44.6MB 1037ms 17ms openjdk 19
java 2-m.java 647ms 16ms 44.4MB 1083ms 50ms openjdk/zgc 19