Typescript VS Java benchmarks

Current benchmark data was generated on Wed Sep 28 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 661ms 5.8ms 413.5MB 667ms 97ms openjdk 20
java 2.java 688ms 18ms 682.2MB 753ms 163ms graal/jvm 17.0.4
java 2.java 717ms 66ms 602.1MB 687ms 130ms openjdk 19
java 2.java 1278ms 15ms 1070.2MB 913ms 580ms openjdk/zgc 19
typescript 1.ts 3437ms 95ms 199.6MB 3450ms 577ms deno 1.25.4

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 135ms 1.5ms 50.6MB 130ms 10ms deno 1.25.4
java 2.java 166ms 4.3ms 111.0MB 163ms 27ms openjdk 19
java 2.java 166ms 5.0ms 111.8MB 163ms 30ms openjdk 20
java 2.java 181ms 10ms 167.7MB 220ms 47ms graal/jvm 17.0.4
java 2.java 298ms 6.1ms 240.4MB 190ms 147ms openjdk/zgc 19

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 1976ms 12ms 71.7MB 1987ms 27ms deno 1.25.4
java 1-m.java 3620ms 824ms 205.3MB 6910ms 70ms openjdk 19
java 1-m.java 4184ms 48ms 906.5MB 7547ms 477ms openjdk/zgc 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
typescript 1.ts 176ms 3.7ms 44.2MB 167ms 0ms deno 1.25.4
java 1-m.java 731ms 60ms 115.1MB 1300ms 40ms openjdk 19
java 1-m.java 977ms 76ms 308.1MB 1610ms 147ms openjdk/zgc 19
java 1-m.java 1030ms 37ms 113.9MB 1887ms 27ms openjdk 20

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 4.java 511ms 4.4ms 41.8MB 593ms 13ms openjdk 20
java 4.java 516ms 1.0ms 41.9MB 590ms 17ms openjdk 19
java 4.java 554ms 4.2ms 41.9MB 597ms 47ms openjdk/zgc 19
java 4-m.java 609ms 4.5ms 118.1MB 900ms 40ms graal/jvm 17.0.4
typescript 1.ts 2116ms 52ms 37.9MB 1977ms 123ms deno 1.25.4

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 4.java 141ms 2.2ms 41.2MB 167ms 7ms openjdk 20
java 4.java 142ms 0.5ms 43.1MB 163ms 13ms openjdk 19
java 4.java 160ms 17ms 101.0MB 200ms 33ms graal/jvm 17.0.4
java 4.java 185ms 2.6ms 41.2MB 173ms 47ms openjdk/zgc 19
typescript 1.ts 272ms 7.2ms 38.2MB 230ms 17ms deno 1.25.4

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 29ms 1.1ms 31.2MB 16ms 0ms deno 1.25.4
java 1.java 68ms 0.5ms 52.8MB 62ms 10ms graal/jvm 17.0.4
java 1.java 76ms 1.1ms 42.4MB 72ms 10ms openjdk 19
java 1.java 78ms 3.8ms 42.5MB 74ms 4ms openjdk 20
java 1.java 119ms 4.4ms 41.8MB 70ms 54ms openjdk/zgc 19

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 1006ms 4.6ms 136.7MB 1243ms 260ms deno 1.25.4
typescript 2.ts 1038ms 11ms 143.9MB 1280ms 270ms deno 1.25.4
typescript 2-tls.ts 1240ms 8.6ms 150.2MB 1427ms 333ms deno 1.25.4
typescript 1-http2.ts 1607ms 254ms 152.0MB 1467ms 323ms deno 1.25.4

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 2.ts 221ms 14ms 73.1MB 170ms 60ms deno 1.25.4
typescript 1.ts 229ms 11ms 77.0MB 177ms 57ms deno 1.25.4
typescript 1-http2.ts 276ms 35ms 75.8MB 230ms 50ms deno 1.25.4
typescript 2-tls.ts 391ms 11ms 83.2MB 347ms 50ms deno 1.25.4

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 149ms 1.3ms 64.4MB 133ms 17ms deno 1.25.4

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 1137ms 2.5ms 262.4MB 1213ms 97ms deno 1.25.4

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 2.ts 654ms 2.5ms 44.1MB 643ms 7ms deno 1.25.4
typescript 1.ts 1082ms 0.9ms 42.0MB 1067ms 7ms deno 1.25.4

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 2.ts 1896ms 41ms 50.0MB 1873ms 3ms deno 1.25.4
typescript 1.ts 3201ms 39ms 52.7MB 3160ms 10ms deno 1.25.4

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 2.ts 331ms 0.5ms 38.0MB 333ms 0ms deno 1.25.4
typescript 1.ts 374ms 2.8ms 35.7MB 363ms 0ms deno 1.25.4

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 488ms 7.7ms 291.8MB 517ms 63ms openjdk 20
java 1.java 503ms 9.9ms 367.5MB 530ms 63ms openjdk 19
java 1.java 550ms 7.1ms 364.9MB 677ms 93ms graal/jvm 17.0.4
typescript 1.ts 660ms 13ms 90.7MB 667ms 17ms deno 1.25.4
java 1.java 924ms 2.7ms 697.8MB 633ms 437ms openjdk/zgc 19

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 210ms 2.6ms 56.5MB 170ms 10ms deno 1.25.4
java 1.java 213ms 3.2ms 171.6MB 247ms 37ms openjdk 20
java 1.java 218ms 6.3ms 174.4MB 233ms 43ms openjdk 19
java 1-m.java 266ms 6.2ms 246.6MB 370ms 63ms graal/jvm 17.0.4
java 1.java 438ms 21ms 355.1MB 273ms 210ms openjdk/zgc 19

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 540ms 3.3ms 87.0MB 580ms 17ms graal/jvm 17.0.4
java 1.java 555ms 3.7ms 42.9MB 573ms 7ms openjdk 19
java 1.java 558ms 2.0ms 42.7MB 577ms 7ms openjdk 20
java 1.java 609ms 7.5ms 42.3MB 590ms 57ms openjdk/zgc 19
typescript 6.ts 651ms 14ms 37.4MB 643ms 0ms deno 1.25.4
java 2.java 1878ms 33ms 547.1MB 1903ms 107ms openjdk 19
java 2.java 1906ms 35ms 551.4MB 1943ms 107ms openjdk 20
java 2.java 2586ms 7.0ms 1209.5MB 2020ms 770ms openjdk/zgc 19

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 6.ts 100ms 1.9ms 37.1MB 90ms 3ms deno 1.25.4
java 1.java 138ms 3.6ms 42.7MB 150ms 13ms openjdk 20
java 1.java 140ms 0.8ms 87.3MB 180ms 27ms graal/jvm 17.0.4
java 1.java 145ms 2.8ms 44.0MB 163ms 7ms openjdk 19
java 1.java 183ms 0.8ms 41.9MB 160ms 57ms openjdk/zgc 19
java 2.java 416ms 11ms 351.8MB 473ms 77ms openjdk 19
java 2.java 422ms 14ms 364.2MB 483ms 87ms openjdk 20
java 2.java 678ms 5.7ms 468.7MB 510ms 327ms openjdk/zgc 19

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 4940ms 2.2ms 335.5MB 5363ms 103ms 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
typescript 3.ts timeout 0.0ms 0.0MB 0ms 0ms deno 1.25.4

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 1342ms 18ms 368.3MB 1683ms 93ms graal/jvm 17.0.4
java 1.java 1409ms 13ms 284.4MB 1800ms 53ms openjdk 19
java 1.java 1429ms 11ms 247.2MB 1780ms 60ms openjdk 20
typescript 3.ts 1508ms 6.0ms 57.7MB 1500ms 77ms deno 1.25.4
java 1.java 2043ms 164ms 1267.1MB 2037ms 687ms openjdk/zgc 19

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 2586ms 5.3ms 39.1MB 2590ms 0ms deno 1.25.4

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 686ms 2.4ms 40.6MB 687ms 3ms deno 1.25.4

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2-m.java 4295ms 13ms 106.8MB 8300ms 30ms graal/jvm 17.0.4
typescript 7.ts 4863ms 22ms 37.1MB 4830ms 7ms deno 1.25.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
java 2-m.java 1244ms 9.2ms 103.8MB 2293ms 37ms graal/jvm 17.0.4
typescript 7.ts 1251ms 11ms 36.9MB 1227ms 3ms deno 1.25.4
java 2-m.java 1603ms 59ms 44.5MB 3043ms 17ms openjdk 20
java 2-m.java 1702ms 192ms 46.3MB 3240ms 13ms openjdk 19
java 2-m.java 1784ms 198ms 42.6MB 3310ms 53ms openjdk/zgc 19

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 7.ts 364ms 2.9ms 37.1MB 327ms 3ms deno 1.25.4
java 2-m.java 431ms 4.5ms 102.8MB 723ms 37ms graal/jvm 17.0.4
java 2-m.java 562ms 23ms 42.3MB 1003ms 17ms openjdk 19
java 2-m.java 594ms 17ms 44.7MB 1067ms 17ms openjdk 20
java 2-m.java 643ms 7.4ms 44.5MB 1073ms 57ms openjdk/zgc 19