Kotlin VS C# 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
kotlin 1.kt 793ms 13ms 413.5MB 770ms 157ms kotlin/jvm 17.0.2
csharp 1.cs 1718ms 34ms 303.4MB 1583ms 217ms dotnet/aot 7.0.102
csharp 1.cs 1977ms 81ms 433.3MB 1717ms 333ms dotnet 7.0.102
csharp 1.cs 2754ms 23ms 106.2MB 3340ms 227ms mono 6.12.0
kotlin 1.kt timeout 0.0ms 194.4MB 8290ms 1107ms kotlin/native 1.8.10

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 155ms 4.2ms 109.3MB 123ms 43ms kotlin/jvm 17.0.2
csharp 1.cs 173ms 7.2ms 60.2MB 137ms 30ms dotnet/aot 7.0.102
csharp 1.cs 190ms 1.8ms 46.1MB 167ms 13ms mono 6.12.0
csharp 1.cs 345ms 16ms 151.8MB 240ms 73ms dotnet 7.0.102
kotlin 1-m.kt 657ms 26ms 34.4MB 1093ms 130ms kotlin/native 1.8.10

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2-m.kt 3597ms 413ms 161.1MB 6813ms 113ms kotlin/jvm 17.0.2
kotlin 1.kt 3783ms 53ms 155.5MB 4727ms 100ms kotlin/jvm 17.0.2
csharp 1.cs timeout 0.0ms 159.0MB 9133ms 113ms dotnet 7.0.102
csharp 1.cs timeout 0.0ms 65.9MB 9127ms 70ms dotnet/aot 7.0.102
kotlin 1.kt timeout 0.0ms 10.8MB 6150ms 310ms kotlin/native 1.8.10
kotlin 2-m.kt timeout 0.0ms 35.5MB 9297ms 157ms kotlin/native 1.8.10

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1-m.cs 374ms 8.9ms 54.9MB 623ms 27ms dotnet/aot 7.0.102
csharp 1-m.cs 729ms 80ms 145.2MB 1137ms 70ms dotnet 7.0.102
kotlin 1-m.kt 826ms 21ms 94.0MB 1427ms 67ms kotlin/jvm 17.0.2
kotlin 2-m.kt 1125ms 20ms 19.5MB 2007ms 60ms kotlin/native 1.8.10
kotlin 2-m.kt 1200ms 149ms 106.7MB 2163ms 60ms kotlin/jvm 17.0.2
kotlin 1.kt 1335ms 37ms 8.9MB 1620ms 73ms kotlin/native 1.8.10

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 2.6ms 0.4ms 1.5MB 0ms 0ms kotlin/native 1.8.10
csharp 1.cs 8.0ms 0.9ms 10.1MB 0ms 0ms dotnet/aot 7.0.102
csharp 1.cs 24ms 1.3ms 23.6MB 10ms 2ms mono 6.12.0
kotlin 1.kt 78ms 1.3ms 40.7MB 62ms 10ms kotlin/jvm 17.0.2
csharp 1.cs 91ms 4.1ms 101.5MB 30ms 32ms dotnet 7.0.102

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2-http2.cs 1129ms 7.3ms 198.2MB 1167ms 170ms dotnet 7.0.102
csharp 2.cs 1150ms 43ms 235.2MB 973ms 657ms dotnet 7.0.102
csharp 1-m.cs 1248ms 24ms 252.7MB 1233ms 663ms dotnet 7.0.102
csharp 2-http3.cs 2141ms 126ms 363.6MB 2693ms 497ms dotnet 7.0.102
kotlin 1.kt timeout 0.0ms 239.0MB 8937ms 550ms kotlin/jvm 17.0.2
kotlin 2.kt timeout 0.0ms 290.5MB 8860ms 547ms kotlin/jvm 17.0.2

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 607ms 25ms 158.8MB 497ms 173ms dotnet 7.0.102
csharp 1.cs 697ms 40ms 172.1MB 660ms 237ms dotnet 7.0.102
csharp 2-http2.cs 973ms 6.4ms 165.2MB 897ms 153ms dotnet 7.0.102
csharp 2-http3.cs 1082ms 25ms 178.1MB 1060ms 167ms dotnet 7.0.102
kotlin 2.kt 2885ms 302ms 195.7MB 3507ms 273ms kotlin/jvm 17.0.2
kotlin 1-m.kt 3422ms 196ms 183.7MB 5610ms 430ms kotlin/jvm 17.0.2

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 502ms 7.6ms 145.0MB 407ms 60ms dotnet 7.0.102
csharp 1.cs 807ms 5.6ms 217.9MB 770ms 117ms dotnet 7.0.102
kotlin 1-m.kt 1346ms 36ms 211.9MB 2263ms 103ms kotlin/jvm 17.0.2

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 2278ms 139ms 342.6MB 2337ms 183ms dotnet 7.0.102
csharp 1.cs 3460ms 49ms 859.9MB 3380ms 483ms dotnet 7.0.102
kotlin 1.kt timeout 0.0ms 890.0MB 7643ms 330ms kotlin/jvm 17.0.2

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 165ms 1.5ms 10.2MB 160ms 0ms dotnet/aot 7.0.102
csharp 2.cs 247ms 7.9ms 27.3MB 227ms 3ms mono 6.12.0
csharp 2.cs 272ms 2.4ms 102.2MB 213ms 27ms dotnet 7.0.102
kotlin 2-m.kt 300ms 6.2ms 113.5MB 417ms 47ms kotlin/jvm 17.0.2
kotlin 1.kt 303ms 5.8ms 109.7MB 373ms 30ms kotlin/jvm 17.0.2
kotlin 2-m.kt 531ms 3.3ms 42.3MB 777ms 33ms kotlin/native 1.8.10
csharp 1.cs 1879ms 12ms 56.1MB 1850ms 27ms dotnet/aot 7.0.102
csharp 1.cs 2048ms 2.1ms 145.7MB 1967ms 67ms dotnet 7.0.102
csharp 1.cs 4010ms 16ms 47.7MB 3953ms 50ms mono 6.12.0
kotlin 1.kt timeout 0.0ms 15.0MB 5003ms 7ms kotlin/native 1.8.10

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 492ms 13ms 10.1MB 483ms 0ms dotnet/aot 7.0.102
kotlin 2.kt 497ms 17ms 130.5MB 600ms 57ms kotlin/jvm 17.0.2
csharp 2.cs 535ms 11ms 101.9MB 483ms 30ms dotnet 7.0.102
kotlin 1.kt 592ms 9.7ms 132.2MB 643ms 43ms kotlin/jvm 17.0.2
csharp 2.cs 634ms 5.8ms 25.3MB 617ms 3ms mono 6.12.0
kotlin 2-m.kt 1648ms 11ms 114.0MB 2420ms 93ms kotlin/native 1.8.10
csharp 1.cs timeout 0.0ms 146.6MB 4930ms 57ms dotnet 7.0.102
csharp 1.cs timeout 0.0ms 56.4MB 4970ms 23ms dotnet/aot 7.0.102
csharp 1.cs timeout 0.0ms 47.9MB 4960ms 33ms mono 6.12.0
kotlin 1.kt timeout 0.0ms 15.0MB 4997ms 10ms kotlin/native 1.8.10

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 85ms 0.6ms 8.1MB 80ms 0ms dotnet/aot 7.0.102
csharp 2.cs 132ms 0.6ms 25.3MB 120ms 0ms mono 6.12.0
csharp 2.cs 190ms 5.7ms 102.2MB 127ms 30ms dotnet 7.0.102
kotlin 1.kt 220ms 4.7ms 77.2MB 297ms 30ms kotlin/jvm 17.0.2
kotlin 2-m.kt 221ms 14ms 78.5MB 307ms 40ms kotlin/jvm 17.0.2
kotlin 2-m.kt 264ms 5.1ms 32.3MB 410ms 20ms kotlin/native 1.8.10
csharp 1.cs timeout 0.0ms 137.6MB 4907ms 57ms dotnet 7.0.102
csharp 1.cs timeout 0.0ms 51.2MB 4953ms 40ms dotnet/aot 7.0.102
csharp 1.cs timeout 0.0ms 29.4MB 4967ms 0ms mono 6.12.0
kotlin 1.kt timeout 0.0ms 17.1MB 4997ms 13ms kotlin/native 1.8.10

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 580ms 1.6ms 363.2MB 553ms 110ms kotlin/jvm 17.0.2
csharp 2.cs 1053ms 5.7ms 382.4MB 917ms 193ms dotnet/aot 7.0.102
csharp 1.cs 1147ms 32ms 303.2MB 1003ms 183ms dotnet/aot 7.0.102
csharp 2.cs 1283ms 16ms 497.2MB 1037ms 270ms dotnet 7.0.102
csharp 1.cs 1342ms 22ms 501.9MB 1127ms 263ms dotnet 7.0.102
csharp 1.cs 2174ms 53ms 142.9MB 2760ms 160ms mono 6.12.0
kotlin 1-m.kt 3664ms 86ms 138.6MB 5797ms 787ms kotlin/native 1.8.10

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 234ms 5.3ms 221.4MB 200ms 63ms kotlin/jvm 17.0.2
csharp 2.cs 249ms 14ms 141.6MB 183ms 60ms dotnet/aot 7.0.102
csharp 1.cs 308ms 9.8ms 190.9MB 203ms 93ms dotnet/aot 7.0.102
csharp 1.cs 399ms 3.3ms 72.0MB 393ms 33ms mono 6.12.0
csharp 1.cs 444ms 10ms 249.0MB 327ms 103ms dotnet 7.0.102
csharp 2.cs 463ms 4.4ms 208.9MB 367ms 77ms dotnet 7.0.102
kotlin 1-m.kt 732ms 13ms 38.4MB 1173ms 133ms kotlin/native 1.8.10

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 9.cs 531ms 2.8ms 98.0MB 463ms 33ms dotnet 7.0.102
csharp 8.cs 686ms 14ms 12.3MB 680ms 0ms dotnet/aot 7.0.102
csharp 8.cs 742ms 6.0ms 99.9MB 673ms 37ms dotnet 7.0.102
kotlin 1.kt 768ms 9.5ms 42.9MB 757ms 27ms kotlin/jvm 17.0.2
kotlin 1n.kt 837ms 45ms 1.5MB 827ms 0ms kotlin/native 1.8.10
csharp 8.cs 1535ms 1.6ms 25.0MB 1513ms 3ms mono 6.12.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 8.cs 78ms 3.2ms 10.0MB 73ms 0ms dotnet/aot 7.0.102
kotlin 1n.kt 88ms 3.6ms 1.5MB 80ms 0ms kotlin/native 1.8.10
csharp 9.cs 144ms 2.8ms 98.4MB 83ms 33ms dotnet 7.0.102
csharp 8.cs 172ms 6.9ms 102.3MB 117ms 27ms dotnet 7.0.102
csharp 8.cs 181ms 0.8ms 25.0MB 157ms 3ms mono 6.12.0
kotlin 1.kt 185ms 11ms 43.0MB 183ms 20ms kotlin/jvm 17.0.2

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs timeout 0.0ms 155.9MB 4923ms 147ms dotnet 7.0.102
csharp 1.cs timeout 0.0ms 57.3MB 4960ms 33ms dotnet/aot 7.0.102
kotlin 1.kt timeout 0.0ms 204.7MB 5390ms 100ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 14.9MB 6577ms 220ms kotlin/native 1.8.10
kotlin 2n.kt timeout 0.0ms 8.4MB 5067ms 107ms kotlin/native 1.8.10

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 1333ms 7.2ms 56.5MB 1290ms 33ms dotnet/aot 7.0.102
csharp 1.cs 1458ms 0.2ms 156.3MB 1413ms 90ms dotnet 7.0.102
kotlin 1.kt 1691ms 16ms 244.6MB 2053ms 87ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 22.9MB 6607ms 190ms kotlin/native 1.8.10
kotlin 2n.kt timeout 0.0ms 10.4MB 5077ms 100ms kotlin/native 1.8.10

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5.cs 3780ms 13ms 600.5MB 3770ms 253ms dotnet 7.0.102
csharp 6.cs 4186ms 22ms 591.0MB 4060ms 253ms dotnet 7.0.102
csharp 6.cs 4329ms 8.4ms 504.8MB 4173ms 210ms dotnet/aot 7.0.102
csharp 5.cs timeout 0.0ms 185.8MB 4950ms 103ms dotnet/aot 7.0.102
kotlin 1.kt timeout 0.0ms 161.4MB 5357ms 67ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 277.3MB 5270ms 943ms kotlin/native 1.8.10

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6.cs 461ms 10ms 73.9MB 433ms 27ms dotnet/aot 7.0.102
csharp 5.cs 575ms 9.7ms 168.1MB 487ms 70ms dotnet 7.0.102
csharp 6.cs 669ms 16ms 163.9MB 573ms 70ms dotnet 7.0.102
csharp 5.cs 841ms 9.2ms 72.1MB 797ms 43ms dotnet/aot 7.0.102
kotlin 1.kt 1213ms 13ms 96.9MB 1667ms 37ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 65.1MB 6333ms 47ms kotlin/native 1.8.10

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs timeout 0.0ms 150.9MB 4957ms 53ms dotnet 7.0.102
csharp 1.cs timeout 0.0ms 60.0MB 4970ms 23ms dotnet/aot 7.0.102
kotlin 1.kt timeout 0.0ms 182.5MB 5997ms 97ms kotlin/jvm 17.0.2

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 1271ms 11ms 57.9MB 1233ms 33ms dotnet/aot 7.0.102
csharp 1.cs 1465ms 51ms 148.9MB 1420ms 63ms dotnet 7.0.102
kotlin 1-m.kt 1604ms 20ms 182.9MB 2433ms 83ms kotlin/jvm 17.0.2