Nim VS Typescript benchmarks

Current benchmark data was generated on Wed Feb 08 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8171M 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
nim 2.nim 2517ms 18ms 33.9MB 2493ms 3ms nim 1.6.10
nim 2.nim 2531ms 9.3ms 34.8MB 2507ms 7ms nim/clang 1.6.10
typescript 1.ts 4812ms 25ms 128.2MB 4840ms 787ms deno 1.30.3

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 227ms 2.5ms 57.2MB 260ms 17ms deno 1.30.3
nim 2.nim 239ms 0.4ms 5.7MB 227ms 0ms nim/clang 1.6.10
nim 2.nim 240ms 1.4ms 5.5MB 220ms 0ms nim 1.6.10

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 2147ms 6.6ms 70.7MB 2157ms 47ms deno 1.30.3
nim 1.nim timeout 0.0ms 405.0MB 3300ms 1353ms nim 1.6.10
nim 1.nim timeout 0.0ms 405.5MB 3347ms 1307ms nim/clang 1.6.10

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 190ms 6.0ms 44.9MB 173ms 10ms deno 1.30.3
nim 1.nim timeout 0.0ms 405.3MB 3357ms 1303ms nim 1.6.10
nim 1.nim timeout 0.0ms 407.5MB 3353ms 1290ms nim/clang 1.6.10

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim timeout 0.0ms 3.1MB 4990ms 0ms nim 1.6.10
nim 1.nim timeout 0.0ms 3.0MB 4983ms 0ms nim/clang 1.6.10

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim timeout 0.0ms 2.3MB 4983ms 0ms nim 1.6.10
nim 1.nim timeout 0.0ms 2.2MB 4980ms 0ms nim/clang 1.6.10

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 291ms 3.7ms 1.0MB 277ms 0ms nim 1.6.10
nim 2.nim 367ms 10.0ms 1.3MB 353ms 0ms nim/clang 1.6.10
nim 1.nim 823ms 13ms 1.3MB 707ms 97ms nim/clang 1.6.10
nim 1.nim 839ms 20ms 1.0MB 723ms 100ms nim 1.6.10
typescript 1.ts 2549ms 22ms 38.9MB 2393ms 163ms deno 1.30.3

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 34ms 2.2ms 1.1MB 20ms 0ms nim 1.6.10
nim 2.nim 39ms 0.2ms 1.3MB 30ms 0ms nim/clang 1.6.10
nim 1.nim 84ms 1.5ms 1.2MB 63ms 7ms nim/clang 1.6.10
nim 1.nim 89ms 0.6ms 1.1MB 67ms 7ms nim 1.6.10
typescript 1.ts 303ms 11ms 38.9MB 290ms 20ms deno 1.30.3

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 2.1ms 0.5ms 1.0MB 0ms 0ms nim 1.6.10
nim 1.nim 2.3ms 0.9ms 1.9MB 0ms 0ms nim/clang 1.6.10
typescript 1.ts 30ms 2.7ms 33.1MB 14ms 6ms deno 1.30.3

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 954ms 7.7ms 94.1MB 447ms 470ms nim/clang 1.6.10
nim 1.nim 989ms 9.0ms 94.7MB 460ms 487ms nim 1.6.10
typescript 2.ts 1307ms 20ms 135.4MB 1433ms 427ms deno 1.30.3
typescript 1.ts 1353ms 24ms 135.5MB 1503ms 430ms deno 1.30.3
typescript 1-http2.ts 1676ms 22ms 139.0MB 1820ms 480ms deno 1.30.3
typescript 2-tls.ts timeout 0.0ms 283.5MB 4827ms 717ms deno 1.30.3

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 154ms 1.8ms 17.8MB 63ms 73ms nim 1.6.10
nim 1.nim 158ms 3.7ms 18.1MB 60ms 83ms nim/clang 1.6.10
typescript 1.ts 268ms 12ms 74.5MB 187ms 83ms deno 1.30.3
typescript 2.ts 284ms 27ms 72.1MB 207ms 57ms deno 1.30.3
typescript 1-http2.ts 335ms 5.6ms 65.9MB 253ms 77ms deno 1.30.3
typescript 2-tls.ts 452ms 13ms 75.8MB 343ms 100ms deno 1.30.3

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 180ms 1.4ms 1.3MB 170ms 0ms nim/clang 1.6.10
nim 2.nim 184ms 1.5ms 1.0MB 170ms 0ms nim 1.6.10
typescript 2.ts 454ms 1.0ms 44.7MB 447ms 10ms deno 1.30.3
typescript 1.ts 846ms 1.4ms 43.5MB 837ms 3ms deno 1.30.3
nim 1.nim timeout 0.0ms 1.1MB 4983ms 0ms nim 1.6.10
nim 1.nim timeout 0.0ms 1.2MB 4987ms 0ms nim/clang 1.6.10

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 535ms 14ms 1.3MB 520ms 0ms nim/clang 1.6.10
nim 2.nim 540ms 0.9ms 1.1MB 530ms 0ms nim 1.6.10
typescript 2.ts 1271ms 13ms 43.4MB 1260ms 13ms deno 1.30.3
typescript 1.ts 2451ms 1.2ms 43.3MB 2430ms 10ms deno 1.30.3
nim 1.nim timeout 0.0ms 1.0MB 4990ms 0ms nim 1.6.10
nim 1.nim timeout 0.0ms 1.3MB 4983ms 0ms nim/clang 1.6.10

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 77ms 2.3ms 1.2MB 67ms 0ms nim/clang 1.6.10
nim 2.nim 80ms 1.7ms 1.0MB 70ms 0ms nim 1.6.10
typescript 2.ts 237ms 2.9ms 37.9MB 230ms 3ms deno 1.30.3
typescript 1.ts 280ms 4.0ms 38.0MB 263ms 7ms deno 1.30.3
nim 1.nim 449ms 7.2ms 1.3MB 437ms 0ms nim/clang 1.6.10
nim 1.nim 496ms 1.6ms 1.0MB 483ms 0ms nim 1.6.10

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 697ms 0.6ms 4.8MB 687ms 0ms nim/clang 1.6.10
nim 1.nim 1040ms 3.5ms 4.4MB 1030ms 0ms nim 1.6.10

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 33ms 0.4ms 1.3MB 20ms 0ms nim/clang 1.6.10
nim 1.nim 49ms 1.0ms 1.0MB 40ms 0ms nim 1.6.10

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 870ms 11ms 89.8MB 880ms 40ms deno 1.30.3
nim 1.nim 1276ms 2.5ms 35.1MB 1243ms 10ms nim/clang 1.6.10
nim 1.nim 1294ms 0.4ms 34.6MB 1267ms 7ms nim 1.6.10

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 228ms 3.1ms 59.3MB 237ms 17ms deno 1.30.3
nim 1.nim 275ms 0.8ms 9.3MB 260ms 0ms nim 1.6.10
nim 1.nim 275ms 4.2ms 9.5MB 260ms 0ms nim/clang 1.6.10

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 489ms 4.9ms 1.2MB 477ms 0ms nim/clang 1.6.10
nim 2.nim 489ms 14ms 1.3MB 477ms 0ms nim 1.6.10
typescript 6.ts 912ms 32ms 37.5MB 900ms 3ms deno 1.30.3

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 52ms 1.6ms 1.3MB 43ms 0ms nim 1.6.10
nim 2.nim 53ms 2.1ms 1.2MB 40ms 0ms nim/clang 1.6.10
typescript 6.ts 130ms 8.1ms 36.8MB 110ms 10ms deno 1.30.3

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 782ms 1.9ms 6.3MB 770ms 0ms nim/clang 1.6.10
nim 2.nim 988ms 18ms 6.0MB 973ms 0ms nim 1.6.10
nim 1.nim 1048ms 48ms 41.3MB 1023ms 10ms nim/clang 1.6.10
nim 1.nim 1053ms 31ms 40.6MB 1027ms 7ms nim 1.6.10

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 153ms 1.5ms 11.1MB 140ms 0ms nim 1.6.10
nim 1.nim 156ms 2.8ms 11.3MB 140ms 0ms nim/clang 1.6.10
nim 2.nim 174ms 4.5ms 3.2MB 163ms 0ms nim/clang 1.6.10
nim 2.nim 240ms 7.1ms 3.1MB 230ms 0ms nim 1.6.10

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim timeout 0.0ms 5.6MB 4990ms 0ms nim 1.6.10
nim 1.nim timeout 0.0ms 5.8MB 4987ms 0ms nim/clang 1.6.10
typescript 3.ts timeout 0.0ms 76.9MB 4990ms 27ms deno 1.30.3

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 3.ts 1749ms 21ms 57.1MB 1670ms 87ms deno 1.30.3
nim 1.nim timeout 0.0ms 5.6MB 4983ms 0ms nim 1.6.10
nim 1.nim timeout 0.0ms 5.8MB 4990ms 0ms nim/clang 1.6.10

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 2873ms 14ms 168.2MB 2813ms 40ms nim/clang 1.6.10
nim 1.nim 2937ms 11ms 166.9MB 2870ms 50ms nim 1.6.10

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 295ms 9.2ms 17.1MB 277ms 3ms nim/clang 1.6.10
nim 1.nim 299ms 3.5ms 16.7MB 280ms 0ms nim 1.6.10

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 4075ms 23ms 1.2MB 4060ms 0ms nim/clang 1.6.10
nim 1.nim 4100ms 19ms 1.3MB 4087ms 0ms nim 1.6.10
typescript 7.ts timeout 0.0ms 38.2MB 4987ms 3ms deno 1.30.3

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 1028ms 4.7ms 1.3MB 1020ms 0ms nim 1.6.10
nim 1.nim 1040ms 16ms 1.2MB 1027ms 0ms nim/clang 1.6.10
typescript 7.ts 1621ms 1.0ms 38.3MB 1603ms 10ms deno 1.30.3

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 261ms 1.5ms 1.2MB 250ms 0ms nim/clang 1.6.10
nim 1.nim 262ms 2.0ms 1.3MB 250ms 0ms nim 1.6.10
typescript 7.ts 488ms 84ms 38.4MB 433ms 7ms deno 1.30.3