Javascript VS C# 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
csharp 1.cs 934ms 19ms 178.8MB 943ms 113ms dotnet/aot 9.0.101
csharp 1.cs 937ms 13ms 190.1MB 943ms 147ms dotnet 9.0.101
javascript 1-m.js 948ms 19ms 199.4MB 1457ms 273ms bun 1.1.42
javascript 1-m.js 1223ms 9.8ms 294.3MB 2110ms 150ms node 23.5.0
csharp 1.cs 1755ms 97ms 101.4MB 1977ms 223ms mono 6.12.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
csharp 1.cs 116ms 6.0ms 40.9MB 90ms 20ms dotnet/aot 9.0.101
javascript 1.js 124ms 2.0ms 82.5MB 120ms 33ms node 23.5.0
csharp 1.cs 145ms 4.8ms 46.0MB 123ms 13ms mono 6.12.0
csharp 1.cs 202ms 19ms 61.8MB 153ms 33ms dotnet 9.0.101

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
javascript 1.js 2195ms 13ms 99.3MB 2210ms 63ms bun 1.1.42
csharp 1-m.cs 2209ms 28ms 66.3MB 7577ms 63ms dotnet/aot 9.0.101
csharp 1-m.cs 2697ms 176ms 81.2MB 8370ms 97ms dotnet 9.0.101

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
csharp 1-m.cs 174ms 1.5ms 29.0MB 487ms 20ms dotnet/aot 9.0.101
javascript 1.js 181ms 3.1ms 85.1MB 203ms 27ms bun 1.1.42
csharp 1-m.cs 275ms 10ms 50.2MB 780ms 23ms dotnet 9.0.101

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
javascript 1.js 718ms 5.1ms 76.4MB 690ms 23ms bun 1.1.42
csharp 1.cs 4071ms 3.4ms 24.3MB 4037ms 20ms dotnet/aot 9.0.101
csharp 1.cs 4961ms 18ms 43.9MB 4927ms 20ms dotnet 9.0.101

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
javascript 1.js 524ms 4.8ms 66.2MB 503ms 13ms bun 1.1.42
csharp 1.cs 677ms 3.5ms 20.4MB 660ms 7ms dotnet/aot 9.0.101
csharp 1.cs 867ms 0.8ms 40.1MB 840ms 20ms dotnet 9.0.101

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 11ms 8.6ms 15.6MB 0ms 0ms dotnet/aot 9.0.101
javascript 1.js 12ms 0.6ms 31.5MB 10ms 0ms bun 1.1.42
csharp 1.cs 30ms 0.6ms 21.9MB 16ms 2ms mono 6.12.0
javascript 1.js 31ms 0.3ms 51.9MB 14ms 6ms node 23.5.0
csharp 1.cs 36ms 0.9ms 32.0MB 16ms 12ms dotnet 9.0.101

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
csharp 2-http2.cs 533ms 7.2ms 122.6MB 737ms 133ms dotnet 9.0.101
csharp 2-m.cs 684ms 22ms 160.8MB 757ms 610ms dotnet 9.0.101
csharp 2-http3.cs 697ms 20ms 158.8MB 1157ms 253ms dotnet 9.0.101
csharp 1-m.cs 813ms 30ms 175.3MB 1137ms 680ms dotnet 9.0.101
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
csharp 2.cs 394ms 16ms 98.6MB 380ms 197ms dotnet 9.0.101
csharp 2-http2.cs 446ms 18ms 97.9MB 487ms 100ms dotnet 9.0.101
csharp 1-m.cs 451ms 7.4ms 109.4MB 503ms 257ms dotnet 9.0.101
csharp 2-http3.cs 496ms 4.0ms 108.0MB 593ms 110ms dotnet 9.0.101

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
csharp 2.cs 311ms 8.5ms 80.3MB 267ms 33ms dotnet 9.0.101
csharp 1.cs 740ms 56ms 153.6MB 767ms 90ms dotnet 9.0.101

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
csharp 2.cs 1582ms 48ms 224.7MB 1747ms 110ms dotnet 9.0.101
csharp 1.cs 2569ms 44ms 756.5MB 2873ms 410ms dotnet 9.0.101

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 95ms 1.0ms 13.8MB 80ms 3ms dotnet/aot 9.0.101
csharp 2.cs 147ms 2.3ms 24.5MB 133ms 0ms mono 6.12.0
csharp 2.cs 250ms 1.2ms 33.4MB 233ms 10ms dotnet 9.0.101
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
csharp 1.cs 1062ms 6.0ms 15.0MB 1037ms 10ms dotnet/aot 9.0.101
csharp 1.cs 1358ms 84ms 36.9MB 1343ms 20ms dotnet 9.0.101
csharp 1.cs 3290ms 18ms 47.6MB 3247ms 37ms mono 6.12.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 263ms 0.8ms 11.7MB 250ms 0ms dotnet/aot 9.0.101
csharp 2.cs 362ms 9.5ms 24.8MB 347ms 3ms mono 6.12.0
csharp 2.cs 407ms 3.9ms 35.6MB 393ms 7ms dotnet 9.0.101
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
csharp 1.cs 3145ms 6.5ms 17.2MB 3117ms 13ms dotnet/aot 9.0.101
csharp 1.cs 3577ms 12ms 39.1MB 3560ms 23ms dotnet 9.0.101
csharp 1.cs timeout 0.0ms 47.6MB 4937ms 53ms mono 6.12.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 53ms 0.9ms 15.7MB 43ms 0ms dotnet/aot 9.0.101
csharp 2.cs 93ms 3.1ms 22.8MB 83ms 0ms mono 6.12.0
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
csharp 2.cs 174ms 5.4ms 35.3MB 150ms 7ms dotnet 9.0.101
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
csharp 1.cs 1612ms 13ms 36.4MB 1597ms 13ms dotnet 9.0.101
csharp 1.cs 1800ms 3.3ms 16.9MB 1780ms 3ms dotnet/aot 9.0.101
csharp 1.cs 1808ms 4.2ms 30.8MB 1797ms 0ms mono 6.12.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
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
csharp 2.cs 540ms 2.8ms 123.4MB 457ms 110ms dotnet/aot 9.0.101
csharp 1.cs 592ms 9.8ms 152.5MB 530ms 120ms dotnet/aot 9.0.101
csharp 2.cs 680ms 21ms 142.0MB 610ms 117ms dotnet 9.0.101
csharp 1.cs 743ms 44ms 170.9MB 660ms 140ms dotnet 9.0.101
csharp 1.cs 1301ms 44ms 146.2MB 1470ms 203ms mono 6.12.0

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
csharp 2.cs 135ms 1.9ms 64.9MB 100ms 37ms dotnet/aot 9.0.101
csharp 1.cs 154ms 4.0ms 78.9MB 110ms 57ms dotnet/aot 9.0.101
javascript 1.js 156ms 3.1ms 102.3MB 153ms 33ms node 23.5.0
csharp 2.cs 258ms 2.7ms 83.9MB 217ms 43ms dotnet 9.0.101
csharp 1.cs 265ms 1.4ms 73.2MB 223ms 47ms mono 6.12.0
csharp 1.cs 278ms 7.3ms 101.3MB 237ms 57ms dotnet 9.0.101

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 9.cs 359ms 1.6ms 34.0MB 337ms 7ms dotnet 9.0.101
csharp 8.cs 373ms 3.9ms 15.7MB 357ms 0ms dotnet/aot 9.0.101
csharp 8.cs 426ms 13ms 33.8MB 390ms 13ms dotnet 9.0.101
javascript 6.js 455ms 3.5ms 59.6MB 440ms 7ms node 23.5.0
javascript 6.js 659ms 1.5ms 44.6MB 657ms 7ms bun 1.1.42
csharp 8.cs 1248ms 3.3ms 24.1MB 1237ms 0ms mono 6.12.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 8.cs 46ms 0.6ms 15.9MB 33ms 0ms dotnet/aot 9.0.101
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
csharp 9.cs 91ms 0.7ms 33.8MB 70ms 10ms dotnet 9.0.101
csharp 8.cs 104ms 17ms 33.7MB 73ms 7ms dotnet 9.0.101
csharp 8.cs 161ms 1.4ms 22.5MB 147ms 3ms mono 6.12.0

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
csharp 1.cs 2899ms 67ms 19.2MB 2847ms 37ms dotnet/aot 9.0.101
csharp 1.cs 2948ms 33ms 39.5MB 3007ms 53ms dotnet 9.0.101

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
csharp 1.cs 727ms 12ms 16.5MB 683ms 27ms dotnet/aot 9.0.101
csharp 1.cs 998ms 4.7ms 39.4MB 1077ms 27ms dotnet 9.0.101

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 3202ms 11ms 19.7MB 3107ms 90ms dotnet/aot 9.0.101
csharp 1.cs 3575ms 22ms 44.1MB 3557ms 143ms dotnet 9.0.101
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
csharp 1.cs 753ms 3.4ms 19.3MB 713ms 27ms dotnet/aot 9.0.101
csharp 1.cs 975ms 4.5ms 43.7MB 1040ms 57ms dotnet 9.0.101
javascript 3.js 1085ms 5.9ms 74.8MB 1063ms 17ms node 23.5.0

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 3-m.cs 1858ms 0.9ms 18.2MB 7250ms 10ms dotnet/aot 9.0.101
javascript 6-m.js 2147ms 4.1ms 116.2MB 8220ms 60ms node 23.5.0
csharp 3-m.cs 2189ms 252ms 38.0MB 6870ms 10ms dotnet 9.0.101
csharp 3-m.cs 4588ms 37ms 28.7MB 17757ms 13ms mono 6.12.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 3-m.cs 476ms 1.0ms 18.3MB 1810ms 7ms dotnet/aot 9.0.101
csharp 3-m.cs 530ms 2.0ms 37.9MB 1857ms 17ms dotnet 9.0.101
javascript 6-m.js 639ms 4.2ms 115.4MB 2287ms 50ms node 23.5.0
csharp 3-m.cs 1305ms 182ms 34.4MB 4597ms 17ms mono 6.12.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 3-m.cs 129ms 1.1ms 18.5MB 443ms 7ms dotnet/aot 9.0.101
csharp 3-m.cs 179ms 1.4ms 36.5MB 507ms 0ms dotnet 9.0.101
javascript 6-m.js 261ms 2.9ms 113.2MB 807ms 37ms node 23.5.0
csharp 3-m.cs 355ms 13ms 30.3MB 1183ms 10ms mono 6.12.0