Javascript VS Java benchmarks

Current benchmark data was generated on Tue Dec 31 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 428ms 6.0ms 574.2MB 503ms 83ms openjdk 21
java 2-m.java 448ms 5.4ms 648.6MB 620ms 120ms graal/jvm 17.0.8
java 2.java 451ms 8.7ms 650.1MB 557ms 87ms openjdk 23
javascript 1-m.js 867ms 11ms 178.1MB 1290ms 257ms bun 1.1.42
java 2.java 1140ms 6.2ms 1085.8MB 540ms 753ms openjdk/zgc 21
javascript 1-m.js 1182ms 24ms 293.5MB 2050ms 133ms node 23.5.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 91ms 0.7ms 78.5MB 70ms 23ms bun 1.1.42
java 2-m.java 117ms 3.3ms 167.6MB 147ms 30ms openjdk 21
javascript 1.js 117ms 2.5ms 82.6MB 117ms 23ms node 23.5.0
java 2.java 122ms 6.2ms 98.2MB 143ms 33ms openjdk 23
java 2-m.java 153ms 9.8ms 226.4MB 223ms 60ms graal/jvm 17.0.8
java 2.java 289ms 1.8ms 241.5MB 147ms 187ms 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 1518ms 12ms 94.5MB 1590ms 53ms node 23.5.0
java 1-m.java 1839ms 107ms 260.2MB 6950ms 100ms openjdk 21
javascript 1.js 2118ms 133ms 100.0MB 2147ms 50ms bun 1.1.42
java 1-m.java 2281ms 118ms 242.8MB 8683ms 107ms openjdk 23
java 1-m.java 2455ms 149ms 1194.8MB 7670ms 997ms openjdk/zgc 21

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 147ms 3.0ms 76.6MB 137ms 17ms node 23.5.0
javascript 1.js 171ms 7.3ms 85.4MB 197ms 23ms bun 1.1.42
java 1-m.java 393ms 19ms 91.0MB 1263ms 60ms openjdk 23
java 1-m.java 413ms 23ms 131.0MB 1357ms 63ms openjdk 21
java 1-m.java 622ms 34ms 224.1MB 1667ms 243ms openjdk/zgc 21

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 259ms 3.7ms 68.1MB 267ms 27ms node 23.5.0
java 1-m.java 570ms 13ms 400.4MB 1093ms 103ms graal/jvm 17.0.8
java 1-m.java 603ms 36ms 265.8MB 1603ms 53ms openjdk 21
java 1-m.java 638ms 35ms 227.5MB 1663ms 60ms openjdk 23
javascript 1.js 677ms 2.7ms 76.5MB 643ms 23ms bun 1.1.42
java 1-m.java 959ms 5.3ms 553.4MB 1583ms 433ms openjdk/zgc 21

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 119ms 2.5ms 65.5MB 133ms 17ms node 23.5.0
java 1-m.java 295ms 20ms 230.9MB 577ms 60ms graal/jvm 17.0.8
java 1-m.java 325ms 28ms 178.0MB 870ms 47ms openjdk 21
java 1-m.java 338ms 18ms 111.1MB 923ms 40ms openjdk 23
java 1-m.java 473ms 26ms 215.3MB 917ms 210ms openjdk/zgc 21
javascript 1.js 494ms 1.9ms 66.4MB 473ms 17ms 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.4ms 32.1MB 10ms 0ms bun 1.1.42
javascript 1.js 29ms 1.3ms 51.9MB 14ms 4ms node 23.5.0
java 1.java 61ms 1.3ms 58.6MB 60ms 20ms graal/jvm 17.0.8
java 1.java 69ms 2.9ms 44.7MB 66ms 14ms openjdk 23
java 1.java 69ms 1.0ms 43.8MB 72ms 10ms openjdk 21
java 1.java 174ms 5.3ms 44.5MB 80ms 116ms openjdk/zgc 21

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.bun.js 340ms 18ms 72.6MB 90ms 403ms bun 1.1.42
javascript 1.js 2928ms 179ms 188.7MB 2733ms 1360ms node 23.5.0

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.bun.js 148ms 13ms 53.6MB 40ms 93ms bun 1.1.42
javascript 1.js 357ms 7.6ms 84.6MB 350ms 80ms 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 80ms 3.6ms 65.6MB 50ms 13ms bun 1.1.42
javascript 1.js 104ms 1.8ms 79.1MB 97ms 10ms node 23.5.0

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 367ms 2.6ms 207.0MB 337ms 73ms bun 1.1.42
javascript 1.js 657ms 4.1ms 204.7MB 763ms 73ms 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 293ms 0.8ms 66.6MB 287ms 7ms node 23.5.0
javascript 1.js 525ms 5.8ms 64.9MB 510ms 7ms node 23.5.0
javascript 2.js 601ms 2.1ms 122.1MB 653ms 43ms bun 1.1.42
javascript 1.js 777ms 12ms 106.0MB 837ms 80ms bun 1.1.42

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 2.js 794ms 4.4ms 72.4MB 787ms 10ms node 23.5.0
javascript 1.js 1492ms 4.6ms 71.9MB 1477ms 10ms node 23.5.0
javascript 2.js 1695ms 15ms 122.4MB 1797ms 83ms bun 1.1.42
javascript 1.js 2217ms 20ms 109.6MB 2460ms 150ms bun 1.1.42

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 150ms 0.6ms 62.0MB 137ms 3ms node 23.5.0
javascript 2.js 156ms 3.5ms 60.9MB 150ms 7ms node 23.5.0
javascript 1.js 298ms 3.3ms 113.8MB 330ms 67ms bun 1.1.42
javascript 2.js 327ms 2.1ms 125.6MB 343ms 50ms bun 1.1.42

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 377ms 8.2ms 679.9MB 450ms 77ms openjdk 21
java 1.java 383ms 9.9ms 546.0MB 480ms 80ms openjdk 23
java 1-m.java 408ms 27ms 589.2MB 630ms 77ms graal/jvm 17.0.8
javascript 1-m.js 466ms 12ms 137.7MB 597ms 133ms bun 1.1.42
javascript 1.js 493ms 0.8ms 134.3MB 557ms 70ms node 23.5.0
java 1.java 1004ms 16ms 1000.0MB 447ms 697ms openjdk/zgc 21

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 113ms 1.9ms 85.8MB 90ms 37ms bun 1.1.42
javascript 1.js 147ms 2.9ms 102.3MB 150ms 27ms node 23.5.0
java 1-m.java 153ms 0.5ms 206.4MB 210ms 50ms openjdk 21
java 1-m.java 154ms 0.8ms 158.8MB 213ms 47ms openjdk 23
java 1-m.java 210ms 8.6ms 260.7MB 360ms 47ms graal/jvm 17.0.8
java 1.java 386ms 10ms 343.0MB 210ms 247ms openjdk/zgc 21

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 417ms 2.4ms 45.2MB 450ms 13ms openjdk 21
java 1.java 420ms 6.1ms 48.2MB 450ms 20ms openjdk 23
java 1.java 429ms 7.0ms 85.0MB 457ms 27ms graal/jvm 17.0.8
javascript 6.js 442ms 11ms 59.8MB 427ms 7ms node 23.5.0
java 1.java 530ms 6.4ms 46.5MB 450ms 130ms openjdk/zgc 21
javascript 6.js 628ms 10ms 44.6MB 627ms 3ms bun 1.1.42
java 2.java 1166ms 4.4ms 571.8MB 1293ms 77ms openjdk 21
java 2.java 1187ms 9.7ms 717.8MB 1287ms 90ms openjdk 23
java 2.java 3101ms 57ms 2431.6MB 1560ms 1743ms openjdk/zgc 21

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 6.js 72ms 1.0ms 59.9MB 57ms 3ms node 23.5.0
javascript 6.js 82ms 1.6ms 44.8MB 83ms 3ms bun 1.1.42
java 1.java 111ms 2.5ms 45.2MB 137ms 20ms openjdk 21
java 1.java 112ms 0.7ms 87.3MB 130ms 30ms graal/jvm 17.0.8
java 1.java 114ms 1.2ms 48.5MB 140ms 20ms openjdk 23
java 1.java 230ms 5.1ms 46.5MB 150ms 133ms openjdk/zgc 21
java 2-m.java 289ms 6.3ms 348.4MB 407ms 70ms openjdk 23
java 2-m.java 293ms 18ms 355.0MB 440ms 30ms openjdk 21
java 2.java 658ms 2.3ms 536.9MB 437ms 403ms openjdk/zgc 21

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 2386ms 6.1ms 64.1MB 2393ms 10ms node 23.5.0
javascript 1.js 2609ms 9.9ms 82.9MB 2640ms 33ms bun 1.1.42

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 628ms 11ms 61.7MB 623ms 17ms node 23.5.0
javascript 1.js 681ms 5.8ms 82.5MB 680ms 27ms bun 1.1.42

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 3054ms 20ms 378.6MB 3497ms 93ms graal/jvm 17.0.8
java 1.java 3512ms 55ms 352.2MB 4263ms 100ms openjdk 21
java 1.java 3516ms 17ms 467.6MB 4333ms 110ms openjdk 23
javascript 3.js 4744ms 21ms 92.2MB 4720ms 30ms node 23.5.0
java 1.java 4911ms 83ms 1847.1MB 4407ms 1287ms openjdk/zgc 21

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1-m.java 862ms 30ms 376.3MB 1213ms 93ms graal/jvm 17.0.8
java 1-m.java 946ms 37ms 351.6MB 1657ms 93ms openjdk 21
java 1-m.java 959ms 18ms 387.9MB 1673ms 93ms openjdk 23
javascript 3.js 1030ms 4.0ms 74.8MB 1017ms 17ms node 23.5.0
java 1.java 1914ms 12ms 1374.3MB 1617ms 980ms 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 1867ms 20ms 47.6MB 7143ms 20ms openjdk 21
java 2-m.java 1877ms 26ms 49.0MB 7130ms 20ms openjdk 23
java 2-m.java 1981ms 11ms 45.4MB 7137ms 137ms openjdk/zgc 21
javascript 6-m.js 2043ms 5.4ms 114.5MB 7827ms 53ms node 23.5.0
java 2-m.java 2318ms 11ms 100.9MB 8233ms 47ms 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 557ms 2.8ms 48.4MB 1953ms 27ms openjdk 23
java 2-m.java 558ms 2.6ms 47.5MB 1963ms 23ms openjdk 21
javascript 6-m.js 615ms 5.5ms 118.0MB 2180ms 43ms node 23.5.0
java 2-m.java 676ms 7.0ms 45.6MB 1957ms 140ms openjdk/zgc 21
java 2-m.java 688ms 5.7ms 98.9MB 2293ms 57ms 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 229ms 5.7ms 48.4MB 670ms 23ms openjdk 23
java 2-m.java 238ms 14ms 47.6MB 693ms 20ms openjdk 21
javascript 6-m.js 250ms 4.8ms 114.8MB 770ms 47ms node 23.5.0
java 2-m.java 281ms 23ms 101.8MB 823ms 40ms graal/jvm 17.0.8
java 2-m.java 346ms 3.4ms 47.1MB 667ms 133ms openjdk/zgc 21