Kotlin VS C# benchmarks

Current benchmark data was generated on Thu Feb 01 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
kotlin 1.kt 469ms 5.8ms 575.8MB 550ms 80ms kotlin/jvm 21
csharp 1.cs 1213ms 21ms 132.8MB 1443ms 180ms dotnet/aot 8.0.101
csharp 1.cs 1714ms 70ms 109.8MB 1903ms 220ms mono 6.12.0
csharp 1.cs 1868ms 70ms 2126.1MB 710ms 1117ms dotnet 8.0.101
kotlin 1-m.kt 3056ms 54ms 248.5MB 5070ms 700ms kotlin/native 1.8.21

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 92ms 2.7ms 29.1MB 93ms 13ms dotnet/aot 8.0.101
kotlin 1.kt 99ms 0.6ms 158.3MB 107ms 30ms kotlin/jvm 21
csharp 1.cs 142ms 1.4ms 44.9MB 117ms 13ms mono 6.12.0
kotlin 1-m.kt 270ms 4.6ms 28.5MB 430ms 60ms kotlin/native 1.8.21
csharp 1.cs 283ms 5.7ms 229.7MB 130ms 113ms dotnet 8.0.101

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2-m.kt 1773ms 358ms 242.2MB 6577ms 93ms kotlin/jvm 21
kotlin 1.kt 2141ms 6.2ms 220.2MB 3003ms 67ms kotlin/jvm 21
csharp 1-m.cs 2301ms 32ms 38.5MB 7933ms 73ms dotnet/aot 8.0.101
csharp 1-m.cs 2776ms 120ms 746.6MB 7507ms 713ms dotnet 8.0.101
kotlin 1.kt timeout 0.0ms 14.8MB 6140ms 457ms kotlin/native 1.8.21
kotlin 2-m.kt timeout 0.0ms 72.9MB 19063ms 127ms kotlin/native 1.8.21

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1-m.cs 159ms 15ms 29.8MB 443ms 20ms dotnet/aot 8.0.101
csharp 1-m.cs 294ms 6.8ms 93.7MB 733ms 47ms dotnet 8.0.101
kotlin 2-m.kt 404ms 0.7ms 32.8MB 1477ms 27ms kotlin/native 1.8.21
kotlin 1-m.kt 465ms 18ms 74.9MB 1057ms 50ms kotlin/jvm 21
kotlin 1.kt 683ms 4.2ms 10.8MB 820ms 57ms kotlin/native 1.8.21
kotlin 2-m.kt 912ms 14ms 99.8MB 3203ms 77ms kotlin/jvm 21

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 2.3ms 0.1ms 4.7MB 0ms 0ms kotlin/native 1.8.21
csharp 1.cs 12ms 11ms 16.2MB 0ms 0ms dotnet/aot 8.0.101
csharp 1.cs 32ms 0.5ms 23.8MB 18ms 2ms mono 6.12.0
csharp 1.cs 56ms 6.0ms 31.4MB 20ms 2ms dotnet 8.0.101
kotlin 1.kt 58ms 4.5ms 47.3MB 58ms 14ms kotlin/jvm 21

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2-http2.cs 629ms 6.5ms 119.0MB 820ms 160ms dotnet 8.0.101
csharp 2-m.cs 716ms 35ms 148.5MB 767ms 627ms dotnet 8.0.101
csharp 1-m.cs 846ms 24ms 171.9MB 1123ms 817ms dotnet 8.0.101
csharp 2-http3.cs 857ms 32ms 151.8MB 1227ms 317ms dotnet 8.0.101
kotlin 2-m.kt 3188ms 2764ms 353.0MB 15630ms 2370ms kotlin/jvm 21
kotlin 1.kt timeout 0.0ms 405.5MB 16613ms 2393ms kotlin/jvm 21

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 434ms 9.7ms 98.1MB 387ms 183ms dotnet 8.0.101
csharp 1-m.cs 471ms 12ms 106.5MB 527ms 223ms dotnet 8.0.101
csharp 2-http2.cs 559ms 14ms 95.7MB 530ms 123ms dotnet 8.0.101
csharp 2-http3.cs 622ms 17ms 106.2MB 660ms 150ms dotnet 8.0.101
kotlin 2-m.kt 2166ms 328ms 250.2MB 3897ms 460ms kotlin/jvm 21
kotlin 1-m.kt 2399ms 24ms 215.3MB 6757ms 710ms kotlin/jvm 21

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 312ms 1.6ms 80.6MB 257ms 23ms dotnet 8.0.101
csharp 1.cs 740ms 51ms 155.1MB 740ms 90ms dotnet 8.0.101
kotlin 1-m.kt 829ms 56ms 212.4MB 2217ms 83ms kotlin/jvm 21

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 1420ms 45ms 316.0MB 1503ms 157ms dotnet 8.0.101
csharp 1.cs 2325ms 42ms 805.3MB 2287ms 427ms dotnet 8.0.101
kotlin 1-m.kt 2357ms 60ms 1045.0MB 5193ms 157ms kotlin/jvm 21

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 106ms 1.6ms 14.1MB 100ms 0ms dotnet/aot 8.0.101
csharp 2.cs 148ms 4.4ms 23.7MB 133ms 0ms mono 6.12.0
kotlin 1-m.kt 179ms 1.1ms 94.8MB 310ms 17ms kotlin/jvm 21
kotlin 2-m.kt 199ms 5.9ms 100.7MB 413ms 33ms kotlin/jvm 21
csharp 2.cs 275ms 12ms 32.4MB 233ms 10ms dotnet 8.0.101
kotlin 2.kt 303ms 2.6ms 7.8MB 433ms 10ms kotlin/native 1.8.21
kotlin 1.kt 507ms 10ms 7.8MB 607ms 3ms kotlin/native 1.8.21
csharp 1.cs 1019ms 3.2ms 17.3MB 1010ms 10ms dotnet/aot 8.0.101
csharp 1.cs 1444ms 29ms 163.2MB 1333ms 93ms dotnet 8.0.101
csharp 1.cs 3317ms 12ms 48.3MB 3263ms 47ms mono 6.12.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 293ms 5.4ms 12.1MB 287ms 0ms dotnet/aot 8.0.101
kotlin 2-m.kt 302ms 3.3ms 212.9MB 523ms 57ms kotlin/jvm 21
kotlin 1.kt 326ms 4.4ms 204.4MB 440ms 33ms kotlin/jvm 21
csharp 2.cs 358ms 4.8ms 27.1MB 347ms 0ms mono 6.12.0
csharp 2.cs 421ms 6.2ms 34.8MB 383ms 10ms dotnet 8.0.101
kotlin 2.kt 911ms 18ms 7.8MB 1313ms 50ms kotlin/native 1.8.21
kotlin 1.kt 1534ms 5.9ms 7.8MB 1860ms 30ms kotlin/native 1.8.21
csharp 1.cs 3057ms 18ms 17.1MB 3037ms 17ms dotnet/aot 8.0.101
csharp 1.cs 3997ms 26ms 422.9MB 3770ms 203ms dotnet 8.0.101
csharp 1.cs timeout 0.0ms 46.4MB 4930ms 60ms mono 6.12.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 59ms 0.4ms 16.1MB 55ms 5ms dotnet/aot 8.0.101
csharp 2.cs 96ms 0.3ms 25.4MB 83ms 3ms mono 6.12.0
kotlin 2.kt 141ms 2.9ms 5.8MB 193ms 3ms kotlin/native 1.8.21
kotlin 1-m.kt 143ms 4.2ms 90.6MB 260ms 37ms kotlin/jvm 21
kotlin 2-m.kt 158ms 11ms 95.6MB 307ms 40ms kotlin/jvm 21
kotlin 1.kt 180ms 1.3ms 5.8MB 237ms 0ms kotlin/native 1.8.21
csharp 2.cs 195ms 1.6ms 32.5MB 147ms 13ms dotnet 8.0.101
csharp 1.cs 1709ms 2.4ms 16.9MB 1707ms 0ms dotnet/aot 8.0.101
csharp 1.cs 1719ms 9.1ms 86.6MB 1663ms 33ms dotnet 8.0.101
csharp 1.cs 1812ms 7.4ms 29.2MB 1793ms 3ms mono 6.12.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 352ms 3.1ms 677.8MB 383ms 80ms kotlin/jvm 21
csharp 2.cs 520ms 2.4ms 155.2MB 587ms 87ms dotnet/aot 8.0.101
csharp 1.cs 601ms 10ms 107.3MB 693ms 97ms dotnet/aot 8.0.101
csharp 2.cs 1201ms 5.0ms 1295.1MB 493ms 673ms dotnet 8.0.101
csharp 1.cs 1308ms 29ms 144.8MB 1517ms 157ms mono 6.12.0
kotlin 1-m.kt 1499ms 16ms 136.6MB 2307ms 317ms kotlin/native 1.8.21
csharp 1.cs 1565ms 4.3ms 1869.6MB 580ms 943ms dotnet 8.0.101

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 110ms 2.0ms 38.0MB 113ms 17ms dotnet/aot 8.0.101
csharp 1.cs 123ms 1.1ms 48.4MB 130ms 23ms dotnet/aot 8.0.101
kotlin 1.kt 129ms 0.4ms 206.5MB 147ms 47ms kotlin/jvm 21
csharp 1.cs 262ms 7.9ms 73.9MB 237ms 33ms mono 6.12.0
kotlin 1-m.kt 323ms 19ms 40.4MB 467ms 77ms kotlin/native 1.8.21
csharp 2.cs 371ms 4.9ms 305.1MB 183ms 157ms dotnet 8.0.101
csharp 1.cs 441ms 8.6ms 428.5MB 170ms 237ms dotnet 8.0.101

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 8.cs 375ms 1.6ms 14.2MB 370ms 3ms dotnet/aot 8.0.101
csharp 9.cs 383ms 7.2ms 33.1MB 343ms 10ms dotnet 8.0.101
kotlin 1n.kt 406ms 3.4ms 4.6MB 393ms 0ms kotlin/native 1.8.21
csharp 8.cs 433ms 3.3ms 32.9MB 393ms 7ms dotnet 8.0.101
kotlin 1.kt 442ms 1.8ms 49.2MB 497ms 7ms kotlin/jvm 21
csharp 8.cs 1248ms 6.8ms 24.9MB 1230ms 3ms mono 6.12.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1n.kt 44ms 0.9ms 4.6MB 33ms 0ms kotlin/native 1.8.21
csharp 8.cs 48ms 1.3ms 16.1MB 43ms 3ms dotnet/aot 8.0.101
csharp 8.cs 106ms 7.9ms 33.2MB 67ms 10ms dotnet 8.0.101
csharp 9.cs 114ms 2.8ms 33.1MB 77ms 10ms dotnet 8.0.101
kotlin 1-m.kt 120ms 0.3ms 49.4MB 167ms 17ms kotlin/jvm 21
csharp 8.cs 162ms 1.0ms 27.0MB 150ms 0ms mono 6.12.0

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 3233ms 16ms 19.9MB 3110ms 137ms dotnet/aot 8.0.101
kotlin 1.kt 3719ms 43ms 355.7MB 4563ms 90ms kotlin/jvm 21
csharp 1.cs timeout 0.0ms 4256.5MB 3027ms 1923ms dotnet 8.0.101
kotlin 1n.kt timeout 0.0ms 7.5MB 6490ms 283ms kotlin/native 1.8.21
kotlin 2n.kt timeout 0.0ms 8.2MB 4980ms 173ms kotlin/native 1.8.21

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 760ms 5.7ms 19.4MB 723ms 33ms dotnet/aot 8.0.101
kotlin 1-m.kt 976ms 35ms 353.3MB 1717ms 97ms kotlin/jvm 21
csharp 1.cs 1552ms 36ms 1164.4MB 1013ms 597ms dotnet 8.0.101
kotlin 1n.kt timeout 0.0ms 7.4MB 6410ms 283ms kotlin/native 1.8.21
kotlin 2n.kt timeout 0.0ms 8.2MB 5020ms 130ms kotlin/native 1.8.21

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6.cs 1736ms 3.9ms 420.5MB 1720ms 107ms dotnet/aot 8.0.101
csharp 5.cs 2003ms 27ms 442.9MB 2103ms 167ms dotnet 8.0.101
csharp 6.cs 2791ms 7.4ms 441.8MB 2800ms 163ms dotnet 8.0.101
csharp 5.cs 4198ms 19ms 422.4MB 4183ms 120ms dotnet/aot 8.0.101
kotlin 1.kt timeout 0.0ms 173.0MB 5387ms 50ms kotlin/jvm 21
kotlin 1n.kt timeout 0.0ms 279.0MB 4880ms 1073ms kotlin/native 1.8.21

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6.cs 198ms 2.5ms 56.4MB 187ms 20ms dotnet/aot 8.0.101
csharp 5.cs 299ms 0.8ms 79.2MB 253ms 37ms dotnet 8.0.101
csharp 6.cs 407ms 1.8ms 77.2MB 367ms 37ms dotnet 8.0.101
csharp 5.cs 448ms 9.0ms 58.2MB 440ms 10ms dotnet/aot 8.0.101
kotlin 1-m.kt 825ms 28ms 134.0MB 1250ms 40ms kotlin/jvm 21
kotlin 1n.kt 3285ms 241ms 65.0MB 4160ms 13ms kotlin/native 1.8.21

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 2745ms 25ms 17.2MB 2707ms 37ms dotnet/aot 8.0.101
kotlin 1.kt 3058ms 41ms 233.9MB 3943ms 80ms kotlin/jvm 21
csharp 1.cs 3518ms 28ms 1354.7MB 2813ms 747ms dotnet 8.0.101

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 714ms 21ms 14.9MB 703ms 10ms dotnet/aot 8.0.101
kotlin 1-m.kt 975ms 45ms 233.6MB 1800ms 47ms kotlin/jvm 21
csharp 1.cs 1074ms 24ms 365.8MB 920ms 193ms dotnet 8.0.101