Javascript VS Java benchmarks

Current benchmark data was generated on Mon Dec 30 2024, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][4 cores] AMD EPYC 7763 64-Core Processor (Model 1)

* -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 470ms 5.2ms 643.8MB 573ms 93ms openjdk 23
java 2-m.java 503ms 33ms 647.1MB 723ms 113ms graal/jvm 17.0.8
java 2.java 523ms 24ms 572.1MB 573ms 123ms openjdk 21
javascript 1-m.js 948ms 19ms 199.4MB 1457ms 273ms bun 1.1.42
java 2.java 1179ms 21ms 1061.1MB 597ms 750ms openjdk/zgc 21
javascript 1-m.js 1223ms 9.8ms 294.3MB 2110ms 150ms node 23.5.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 96ms 2.2ms 78.6MB 67ms 33ms bun 1.1.42
java 2.java 121ms 3.7ms 167.1MB 147ms 33ms openjdk 21
javascript 1.js 124ms 2.0ms 82.5MB 120ms 33ms node 23.5.0
java 2.java 127ms 6.0ms 98.3MB 160ms 30ms openjdk 23
java 2-m.java 147ms 3.6ms 217.2MB 217ms 50ms graal/jvm 17.0.8
java 2.java 308ms 0.7ms 241.5MB 150ms 210ms openjdk/zgc 21

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 1578ms 6.8ms 94.6MB 1660ms 50ms node 23.5.0
java 1-m.java 1774ms 162ms 260.9MB 6640ms 123ms openjdk 21
javascript 1.js 2195ms 13ms 99.3MB 2210ms 63ms bun 1.1.42
java 1-m.java 2359ms 176ms 242.2MB 8950ms 137ms openjdk 23
java 1-m.java 2678ms 125ms 1210.6MB 8550ms 1040ms openjdk/zgc 21

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 154ms 1.5ms 76.7MB 143ms 17ms node 23.5.0
javascript 1.js 181ms 3.1ms 85.1MB 203ms 27ms bun 1.1.42
java 1-m.java 399ms 60ms 94.6MB 1303ms 47ms openjdk 23
java 1-m.java 407ms 34ms 120.2MB 1323ms 70ms openjdk 21
java 1-m.java 641ms 37ms 215.7MB 1710ms 250ms openjdk/zgc 21

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 270ms 2.7ms 69.0MB 283ms 23ms node 23.5.0
java 1-m.java 604ms 73ms 280.0MB 1673ms 77ms openjdk 21
java 1-m.java 623ms 17ms 357.7MB 1187ms 117ms graal/jvm 17.0.8
java 1-m.java 627ms 58ms 227.7MB 1667ms 57ms openjdk 23
javascript 1.js 718ms 5.1ms 76.4MB 690ms 23ms bun 1.1.42
java 1-m.java 986ms 3.5ms 524.1MB 1717ms 423ms openjdk/zgc 21

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 125ms 2.5ms 65.6MB 140ms 13ms node 23.5.0
java 1-m.java 299ms 20ms 231.8MB 577ms 77ms graal/jvm 17.0.8
java 1-m.java 334ms 14ms 178.4MB 907ms 50ms openjdk 21
java 1-m.java 365ms 5.6ms 111.1MB 990ms 57ms openjdk 23
java 1-m.java 510ms 18ms 215.0MB 1003ms 197ms openjdk/zgc 21
javascript 1.js 524ms 4.8ms 66.2MB 503ms 13ms bun 1.1.42

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 12ms 0.6ms 31.5MB 10ms 0ms bun 1.1.42
javascript 1.js 31ms 0.3ms 51.9MB 14ms 6ms node 23.5.0
java 1.java 63ms 1.7ms 54.7MB 60ms 22ms graal/jvm 17.0.8
java 1.java 66ms 3.8ms 43.8MB 70ms 18ms openjdk 21
java 1.java 68ms 6.1ms 44.7MB 76ms 12ms openjdk 23
java 1.java 187ms 4.7ms 44.6MB 78ms 132ms openjdk/zgc 21

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1-m.bun.js 343ms 27ms 70.2MB 127ms 393ms bun 1.1.42
javascript 1.js 3271ms 270ms 197.4MB 3033ms 1503ms node 23.5.0

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.bun.js 135ms 29ms 54.0MB 27ms 100ms bun 1.1.42
javascript 1.js 390ms 12ms 85.4MB 337ms 130ms node 23.5.0

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 85ms 8.1ms 65.6MB 53ms 20ms bun 1.1.42
javascript 1.js 109ms 1.6ms 79.3MB 93ms 23ms node 23.5.0

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 385ms 1.5ms 206.9MB 353ms 73ms bun 1.1.42
javascript 1.js 687ms 1.9ms 205.2MB 787ms 83ms node 23.5.0

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 2.js 306ms 0.5ms 66.9MB 300ms 10ms node 23.5.0
javascript 1.js 550ms 5.0ms 64.9MB 537ms 7ms node 23.5.0
javascript 2.js 637ms 6.3ms 122.1MB 687ms 57ms bun 1.1.42
javascript 1.js 815ms 6.2ms 105.9MB 870ms 90ms bun 1.1.42

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 2.js 843ms 2.0ms 72.7MB 827ms 20ms node 23.5.0
javascript 1.js 1578ms 7.3ms 71.9MB 1553ms 20ms node 23.5.0
javascript 2.js 1793ms 11ms 122.3MB 1913ms 83ms bun 1.1.42
javascript 1.js 2334ms 4.4ms 105.9MB 2607ms 137ms bun 1.1.42

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 160ms 1.3ms 61.9MB 153ms 3ms node 23.5.0
javascript 2.js 163ms 0.4ms 60.9MB 163ms 3ms node 23.5.0
javascript 1.js 311ms 3.7ms 113.6MB 340ms 70ms bun 1.1.42
javascript 2.js 357ms 12ms 125.4MB 377ms 57ms bun 1.1.42

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 399ms 1.4ms 542.0MB 487ms 93ms openjdk 23
java 1.java 423ms 3.2ms 678.0MB 463ms 120ms openjdk 21
java 1-m.java 432ms 28ms 579.8MB 670ms 87ms graal/jvm 17.0.8
javascript 1-m.js 499ms 5.6ms 135.9MB 660ms 127ms bun 1.1.42
javascript 1.js 520ms 3.2ms 134.5MB 603ms 57ms node 23.5.0
java 1.java 1051ms 32ms 963.0MB 460ms 717ms openjdk/zgc 21

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 119ms 0.9ms 86.1MB 100ms 37ms bun 1.1.42
javascript 1.js 156ms 3.1ms 102.3MB 153ms 33ms node 23.5.0
java 1-m.java 161ms 1.6ms 206.3MB 240ms 30ms openjdk 21
java 1-m.java 162ms 2.8ms 158.4MB 233ms 40ms openjdk 23
java 1-m.java 233ms 27ms 259.4MB 393ms 53ms graal/jvm 17.0.8
java 1.java 416ms 29ms 341.8MB 207ms 283ms openjdk/zgc 21

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 440ms 1.4ms 45.1MB 480ms 17ms openjdk 21
java 1.java 442ms 1.9ms 48.1MB 480ms 10ms openjdk 23
java 1.java 448ms 9.7ms 84.8MB 477ms 23ms graal/jvm 17.0.8
javascript 6.js 455ms 3.5ms 59.6MB 440ms 7ms node 23.5.0
java 1.java 564ms 1.4ms 44.6MB 477ms 143ms openjdk/zgc 21
javascript 6.js 659ms 1.5ms 44.6MB 657ms 7ms bun 1.1.42
java 2.java 1225ms 6.3ms 537.4MB 1353ms 73ms openjdk 21
java 2.java 1260ms 20ms 715.9MB 1367ms 110ms openjdk 23
java 2.java 3206ms 52ms 2355.0MB 1643ms 1770ms openjdk/zgc 21

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 6.js 76ms 0.7ms 59.8MB 63ms 7ms node 23.5.0
javascript 6.js 87ms 0.3ms 44.6MB 77ms 7ms bun 1.1.42
java 1.java 118ms 1.6ms 45.3MB 157ms 17ms openjdk 21
java 1.java 122ms 0.2ms 48.4MB 160ms 10ms openjdk 23
java 1-m.java 122ms 5.7ms 95.3MB 160ms 30ms graal/jvm 17.0.8
java 1.java 245ms 1.2ms 44.5MB 160ms 143ms openjdk/zgc 21
java 2-m.java 296ms 5.5ms 346.7MB 430ms 57ms openjdk 21
java 2-m.java 298ms 3.8ms 394.1MB 427ms 70ms openjdk 23
java 2.java 682ms 11ms 527.4MB 467ms 393ms openjdk/zgc 21

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 2480ms 11ms 64.4MB 2493ms 10ms node 23.5.0
javascript 1.js 2760ms 36ms 83.0MB 2793ms 37ms bun 1.1.42

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 657ms 7.0ms 61.8MB 663ms 13ms node 23.5.0
javascript 1.js 718ms 2.9ms 82.6MB 703ms 37ms bun 1.1.42

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 3168ms 1.6ms 445.4MB 3600ms 83ms graal/jvm 17.0.8
java 1.java 3621ms 25ms 412.3MB 4497ms 110ms openjdk 23
java 1.java 3704ms 51ms 351.8MB 4517ms 123ms openjdk 21
java 1.java timeout 0.0ms 1977.1MB 4647ms 1220ms openjdk/zgc 21
javascript 3.js timeout 0.0ms 92.1MB 4983ms 23ms node 23.5.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 906ms 26ms 373.8MB 1277ms 77ms graal/jvm 17.0.8
java 1-m.java 1002ms 33ms 351.1MB 1813ms 80ms openjdk 21
java 1-m.java 1037ms 4.5ms 395.1MB 1743ms 97ms openjdk 23
javascript 3.js 1085ms 5.9ms 74.8MB 1063ms 17ms node 23.5.0
java 1.java 2001ms 40ms 1342.4MB 1710ms 1033ms openjdk/zgc 21

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2-m.java 1954ms 2.3ms 47.6MB 7430ms 27ms openjdk 21
java 2-m.java 1957ms 10.0ms 48.4MB 7443ms 27ms openjdk 23
java 2-m.java 2087ms 15ms 47.8MB 7507ms 150ms openjdk/zgc 21
javascript 6-m.js 2147ms 4.1ms 116.2MB 8220ms 60ms node 23.5.0
java 2-m.java 2463ms 18ms 101.0MB 8780ms 43ms graal/jvm 17.0.8

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2-m.java 581ms 3.1ms 48.0MB 2053ms 13ms openjdk 21
java 2-m.java 590ms 3.1ms 48.8MB 2057ms 23ms openjdk 23
javascript 6-m.js 639ms 4.2ms 115.4MB 2287ms 50ms node 23.5.0
java 2-m.java 712ms 6.8ms 47.4MB 2073ms 143ms openjdk/zgc 21
java 2-m.java 730ms 13ms 100.2MB 2463ms 43ms graal/jvm 17.0.8

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2-m.java 235ms 9.8ms 47.9MB 683ms 17ms openjdk 21
java 2-m.java 238ms 3.7ms 48.8MB 667ms 27ms openjdk 23
javascript 6-m.js 261ms 2.9ms 113.2MB 807ms 37ms node 23.5.0
java 2-m.java 282ms 17ms 99.0MB 820ms 43ms graal/jvm 17.0.8
java 2-m.java 360ms 7.4ms 47.0MB 673ms 150ms openjdk/zgc 21