Javascript VS Python benchmarks

Current benchmark data was generated on Wed May 25 2022, 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
python 1.py 1831ms 34ms 220.3MB 1667ms 147ms pypy 3.8.13
javascript 1.js 4218ms 14ms 265.6MB 2980ms 1580ms node 18.2.0
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 140ms 3.4ms 78.6MB 107ms 20ms pypy 3.8.13
javascript 1.js 237ms 0.8ms 80.5MB 213ms 33ms node 18.2.0
python 1.py 682ms 3.3ms 12.4MB 657ms 7ms pyston 3.8.12
python 1.py 1619ms 7.5ms 11.8MB 1603ms 0ms cpython 3.10.4

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 1538ms 8.5ms 221.3MB 1423ms 100ms pypy 3.8.13
javascript 1.js 2607ms 120ms 76.4MB 2667ms 50ms node 18.2.0
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 237ms 1.3ms 57.5MB 210ms 23ms node 18.2.0
python 1.py 312ms 8.1ms 90.4MB 270ms 23ms pypy 3.8.13
python 1.py 864ms 4.1ms 17.2MB 843ms 0ms pyston 3.8.12
python 1.py 910ms 2.7ms 17.0MB 887ms 7ms cpython 3.10.4

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 14ms 1.8ms 7.6MB 10ms 0ms pyston 3.8.12
python 1.py 16ms 2.8ms 7.3MB 10ms 0ms cpython 3.10.4
python 1.py 37ms 1.1ms 54.6MB 12ms 10ms pypy 3.8.13
javascript 1.js 50ms 3.0ms 37.6MB 36ms 4ms node 18.2.0

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 1696ms 20ms 29.7MB 1390ms 973ms pyston 3.8.12
python 1.py 2385ms 42ms 29.1MB 2103ms 1053ms cpython 3.10.4
python 1.py 4919ms 7.5ms 131.9MB 3857ms 917ms pypy 3.8.13
javascript 1.js timeout 0.0ms 0.0MB 0ms 0ms node 18.2.0

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 380ms 7.0ms 24.2MB 313ms 160ms pyston 3.8.12
javascript 1.js 399ms 7.4ms 68.0MB 357ms 87ms node 18.2.0
python 1.py 474ms 5.9ms 21.8MB 407ms 180ms cpython 3.10.4
python 1.py 1186ms 25ms 99.4MB 973ms 177ms pypy 3.8.13

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 180ms 2.5ms 70.0MB 153ms 23ms node 18.2.0
python 1.py 278ms 3.3ms 38.9MB 227ms 30ms pyston 3.8.12
python 1.py 282ms 2.0ms 39.5MB 243ms 20ms cpython 3.10.4
python 1.py 454ms 1.0ms 103.8MB 403ms 30ms pypy 3.8.13

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 1217ms 3.5ms 285.3MB 1183ms 150ms node 18.2.0
python 1.py 2590ms 4.0ms 219.6MB 2427ms 143ms cpython 3.10.4
python 1.py 2634ms 4.5ms 221.0MB 2460ms 160ms pyston 3.8.12
python 1.py 2857ms 2.6ms 242.5MB 2740ms 97ms pypy 3.8.13

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 2.py 235ms 0.8ms 74.1MB 203ms 13ms pypy 3.8.13
python 1.py 280ms 0.3ms 75.4MB 250ms 17ms pypy 3.8.13
javascript 2.js 849ms 2.0ms 55.0MB 833ms 7ms node 18.2.0
python 1.py 878ms 5.1ms 9.3MB 867ms 0ms pyston 3.8.12
python 2.py 1055ms 2.7ms 9.1MB 1040ms 0ms pyston 3.8.12
javascript 1.js 1145ms 3.1ms 57.1MB 1117ms 20ms node 18.2.0
python 1.py 1743ms 15ms 8.4MB 1730ms 0ms cpython 3.10.4
python 2.py 2570ms 50ms 8.3MB 2557ms 0ms cpython 3.10.4

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 2.py 562ms 4.3ms 74.6MB 523ms 17ms pypy 3.8.13
python 1.py 614ms 2.1ms 76.1MB 583ms 17ms pypy 3.8.13
javascript 2.js 2393ms 20ms 58.1MB 2380ms 13ms node 18.2.0
python 1.py 2586ms 14ms 9.3MB 2570ms 0ms pyston 3.8.12
python 2.py 3121ms 7.9ms 9.0MB 3107ms 0ms pyston 3.8.12
javascript 1.js 3152ms 220ms 56.9MB 3113ms 30ms node 18.2.0
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4
python 2.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 2.py 167ms 1.7ms 74.0MB 133ms 17ms pypy 3.8.13
python 1.py 184ms 0.5ms 74.3MB 143ms 17ms pypy 3.8.13
python 1.py 431ms 5.2ms 8.9MB 413ms 0ms pyston 3.8.12
javascript 2.js 440ms 2.4ms 46.5MB 423ms 7ms node 18.2.0
javascript 1.js 465ms 0.8ms 42.7MB 443ms 17ms node 18.2.0
python 2.py 487ms 2.4ms 8.5MB 477ms 0ms pyston 3.8.12
python 1.py 811ms 4.9ms 7.8MB 793ms 3ms cpython 3.10.4
python 2.py 1234ms 16ms 7.3MB 1217ms 0ms cpython 3.10.4

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 1071ms 1.7ms 117.0MB 1107ms 53ms node 18.2.0
python 1.py 2988ms 32ms 233.4MB 2767ms 203ms pypy 3.8.13
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 302ms 1.3ms 84.4MB 290ms 33ms node 18.2.0
python 1.py 443ms 13ms 151.0MB 363ms 60ms pypy 3.8.13
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 6.js 721ms 41ms 42.6MB 703ms 3ms node 18.2.0
python 2.py 2271ms 62ms 74.5MB 2243ms 13ms pypy 3.8.13
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4
python 2.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pypy 3.8.13
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12
python 2.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 6.js 132ms 11ms 42.5MB 103ms 13ms node 18.2.0
python 2.py 294ms 5.0ms 74.1MB 253ms 27ms pypy 3.8.13
python 1.py 583ms 1.7ms 73.4MB 557ms 13ms pypy 3.8.13
python 1.py 1420ms 106ms 8.7MB 1407ms 0ms pyston 3.8.12
python 2.py 2057ms 12ms 8.5MB 2043ms 0ms pyston 3.8.12
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4
python 2.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 4.py 2069ms 2.9ms 8.6MB 2037ms 20ms cpython 3.10.4
python 4.py 2237ms 2.1ms 9.4MB 2207ms 10ms pyston 3.8.12
python 4.py 2733ms 28ms 127.6MB 2640ms 73ms pypy 3.8.13
javascript 3.js timeout 0.0ms 0.0MB 0ms 0ms node 18.2.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 4.py 502ms 4.7ms 8.4MB 480ms 0ms cpython 3.10.4
python 4.py 535ms 1.2ms 9.1MB 520ms 0ms pyston 3.8.12
python 4.py 702ms 4.2ms 79.7MB 670ms 20ms pypy 3.8.13
javascript 3.js 1675ms 7.6ms 58.4MB 1663ms 13ms node 18.2.0

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 4145ms 23ms 47.6MB 4160ms 27ms node 18.2.0
python 1.py 4296ms 306ms 8.6MB 4283ms 0ms pyston 3.8.12
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pypy 3.8.13

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 1.js 1049ms 70ms 46.8MB 1057ms 10ms node 18.2.0
python 1.py 1128ms 4.1ms 8.7MB 1113ms 0ms pyston 3.8.12
python 1.py 1465ms 5.2ms 7.3MB 1450ms 0ms cpython 3.10.4
python 1.py 1600ms 4.0ms 80.0MB 1570ms 17ms pypy 3.8.13

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 6-m.js 2983ms 4.9ms 67.0MB 5593ms 30ms node 18.2.0
python 8.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4
python 8.py timeout 0.0ms 0.0MB 0ms 0ms pypy 3.8.13
python 8.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 6-m.js 923ms 9.4ms 65.4MB 1623ms 27ms node 18.2.0
python 8.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4
python 8.py timeout 0.0ms 0.0MB 0ms 0ms pypy 3.8.13
python 8.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
javascript 6-m.js 410ms 6.8ms 65.7MB 593ms 33ms node 18.2.0
python 8-m.py 4206ms 35ms 105.3MB 7317ms 397ms pypy 3.8.13
python 8.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.4
python 8.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12