Kotlin VS C# 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
kotlin 1.kt 646ms 21ms 412.3MB 653ms 97ms kotlin/jvm 17.0.2
csharp 1.cs 1331ms 9.4ms 391.1MB 1237ms 157ms dotnet 6.0.401
csharp 1.cs 2177ms 35ms 102.7MB 2453ms 197ms mono 6.12.0
kotlin 1-m.kt 4834ms 48ms 246.8MB 7880ms 53ms kotlin/native 1.7.10

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 126ms 2.8ms 109.7MB 110ms 30ms kotlin/jvm 17.0.2
csharp 1.cs 151ms 2.5ms 44.6MB 130ms 7ms mono 6.12.0
csharp 1.cs 184ms 6.7ms 90.9MB 140ms 23ms dotnet 6.0.401
kotlin 1-m.kt 415ms 1.2ms 30.5MB 690ms 0ms kotlin/native 1.7.10

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2-m.kt 2872ms 80ms 157.7MB 5470ms 67ms kotlin/jvm 17.0.2
kotlin 1.kt 3016ms 39ms 154.5MB 3863ms 37ms kotlin/jvm 17.0.2
csharp 1-m.cs 4095ms 60ms 104.8MB 6900ms 57ms dotnet 6.0.401
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.10
kotlin 2-m.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.10

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1-m.cs 414ms 34ms 88.5MB 643ms 33ms dotnet 6.0.401
kotlin 1-m.kt 689ms 6.6ms 94.2MB 1210ms 43ms kotlin/jvm 17.0.2
kotlin 2-m.kt 867ms 23ms 29.8MB 1533ms 30ms kotlin/native 1.7.10
kotlin 2-m.kt 1058ms 13ms 103.6MB 1930ms 37ms kotlin/jvm 17.0.2
kotlin 1.kt 1077ms 5.0ms 10.6MB 1237ms 7ms kotlin/native 1.7.10

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 2.4ms 0.6ms 1.1MB 0ms 0ms kotlin/native 1.7.10
csharp 1.cs 18ms 1.2ms 24.3MB 10ms 0ms mono 6.12.0
csharp 1.cs 51ms 1.8ms 29.1MB 20ms 2ms dotnet 6.0.401
kotlin 1.kt 63ms 5.3ms 40.8MB 46ms 10ms kotlin/jvm 17.0.2

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2-http2.cs 631ms 3.1ms 122.6MB 733ms 60ms dotnet 6.0.401
csharp 2-http3.cs 824ms 16ms 270.4MB 890ms 257ms dotnet 7.0.100-rc.1.22431.12
csharp 2.cs 838ms 25ms 147.3MB 770ms 393ms dotnet 6.0.401
csharp 1.cs 890ms 24ms 171.1MB 883ms 440ms dotnet 6.0.401
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/jvm 17.0.2
kotlin 2.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/jvm 17.0.2

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 446ms 12ms 75.3MB 373ms 87ms dotnet 6.0.401
csharp 1.cs 468ms 7.9ms 84.0MB 490ms 90ms dotnet 6.0.401
csharp 2-http2.cs 505ms 7.7ms 80.3MB 517ms 37ms dotnet 6.0.401
csharp 2-http3.cs 512ms 9.3ms 186.7MB 420ms 130ms dotnet 7.0.100-rc.1.22431.12
kotlin 2-m.kt 2265ms 143ms 199.2MB 3520ms 200ms kotlin/jvm 17.0.2
kotlin 1-m.kt 2424ms 263ms 182.4MB 3883ms 237ms 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 359ms 4.0ms 65.8MB 313ms 27ms dotnet 6.0.401
csharp 1.cs 528ms 3.5ms 145.7MB 497ms 53ms dotnet 6.0.401
kotlin 1-m.kt 1139ms 25ms 213.2MB 1950ms 80ms 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 2028ms 4.5ms 275.5MB 2087ms 107ms dotnet 6.0.401
csharp 1.cs 3220ms 136ms 762.9MB 3243ms 340ms dotnet 6.0.401
kotlin 1-m.kt 4079ms 251ms 946.0MB 5950ms 247ms 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 184ms 0.1ms 25.2MB 170ms 0ms mono 6.12.0
csharp 2.cs 199ms 3.1ms 27.6MB 163ms 7ms dotnet 6.0.401
kotlin 1.kt 235ms 2.4ms 109.9MB 300ms 20ms kotlin/jvm 17.0.2
kotlin 2-m.kt 240ms 22ms 118.0MB 360ms 23ms kotlin/jvm 17.0.2
kotlin 2-m.kt 464ms 12ms 54.1MB 747ms 3ms kotlin/native 1.7.10
csharp 1.cs 1743ms 88ms 89.8MB 1700ms 23ms dotnet 6.0.401
csharp 1.cs 3000ms 7.7ms 49.6MB 2960ms 33ms mono 6.12.0
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.10

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2.kt 369ms 0.6ms 130.6MB 470ms 27ms kotlin/jvm 17.0.2
csharp 2.cs 454ms 1.3ms 28.2MB 430ms 3ms dotnet 6.0.401
kotlin 1.kt 454ms 2.5ms 132.8MB 503ms 37ms kotlin/jvm 17.0.2
csharp 2.cs 506ms 7.8ms 25.0MB 490ms 3ms mono 6.12.0
kotlin 2-m.kt 1384ms 2.6ms 146.0MB 2140ms 37ms kotlin/native 1.7.10
csharp 1.cs 4626ms 14ms 90.9MB 4570ms 40ms dotnet 6.0.401
csharp 1.cs timeout 0.0ms 0.0MB 0ms 0ms mono 6.12.0
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.10

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 104ms 1.1ms 25.2MB 100ms 0ms mono 6.12.0
csharp 2.cs 128ms 0.6ms 29.9MB 107ms 0ms dotnet 6.0.401
kotlin 1-m.kt 170ms 2.4ms 75.9MB 250ms 17ms kotlin/jvm 17.0.2
kotlin 2-m.kt 178ms 4.3ms 76.8MB 253ms 20ms kotlin/jvm 17.0.2
kotlin 2-m.kt 237ms 4.8ms 27.9MB 387ms 0ms kotlin/native 1.7.10
csharp 1.cs 3189ms 11ms 30.6MB 3163ms 0ms mono 6.12.0
csharp 1.cs 3191ms 8.4ms 77.3MB 3143ms 23ms dotnet 6.0.401
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.10

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 500ms 21ms 561.1MB 477ms 100ms kotlin/jvm 17.0.2
csharp 1.cs 921ms 4.2ms 391.9MB 793ms 163ms dotnet 6.0.401
csharp 2.cs 927ms 18ms 378.4MB 787ms 173ms dotnet 6.0.401
csharp 1.cs 1675ms 7.1ms 148.6MB 2093ms 110ms mono 6.12.0
kotlin 1.kt 2330ms 9.2ms 138.2MB 3397ms 23ms kotlin/native 1.7.10

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 188ms 3.7ms 221.5MB 170ms 47ms kotlin/jvm 17.0.2
csharp 2.cs 252ms 2.7ms 94.2MB 203ms 30ms dotnet 6.0.401
csharp 1.cs 291ms 3.1ms 185.8MB 197ms 73ms dotnet 6.0.401
csharp 1.cs 306ms 5.3ms 72.7MB 277ms 27ms mono 6.12.0
kotlin 1.kt 425ms 5.9ms 38.1MB 613ms 3ms kotlin/native 1.7.10

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 9.cs 404ms 2.6ms 29.3MB 377ms 3ms dotnet 6.0.401
csharp 8.cs 532ms 4.1ms 25.4MB 503ms 3ms dotnet 6.0.401
kotlin 1n.kt 537ms 3.4ms 1.1MB 527ms 0ms kotlin/native 1.7.10
kotlin 1.kt 566ms 0.2ms 43.2MB 580ms 17ms kotlin/jvm 17.0.2
csharp 8.cs 1107ms 0.7ms 25.1MB 1090ms 0ms mono 6.12.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1n.kt 58ms 0.7ms 1.2MB 50ms 0ms kotlin/native 1.7.10
csharp 9.cs 91ms 6.8ms 29.4MB 63ms 3ms dotnet 6.0.401
csharp 8.cs 103ms 0.3ms 27.3MB 73ms 0ms dotnet 6.0.401
csharp 8.cs 135ms 5.0ms 25.3MB 123ms 0ms mono 6.12.0
kotlin 1.kt 135ms 0.8ms 43.2MB 157ms 10ms 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 4943ms 41ms 94.3MB 4933ms 43ms dotnet 6.0.401
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.10
kotlin 2n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.10

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 1216ms 9.0ms 94.9MB 1203ms 40ms dotnet 6.0.401
kotlin 1.kt 1434ms 9.9ms 207.7MB 1760ms 50ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.10
kotlin 2n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.10

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5.cs 3081ms 14ms 614.1MB 2997ms 247ms dotnet 7.0.100-rc.1.22431.12
csharp 5.cs 4161ms 25ms 528.0MB 4063ms 213ms dotnet 6.0.401
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.10

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5.cs 449ms 4.7ms 180.3MB 383ms 47ms dotnet 7.0.100-rc.1.22431.12
csharp 5.cs 526ms 1.6ms 90.1MB 493ms 17ms dotnet 6.0.401
kotlin 1.kt 1073ms 9.0ms 95.5MB 1470ms 37ms kotlin/jvm 17.0.2
kotlin 1n.kt 4822ms 8.4ms 74.8MB 6053ms 17ms kotlin/native 1.7.10

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 4306ms 30ms 92.8MB 4263ms 33ms dotnet 6.0.401
kotlin 1.kt 4482ms 21ms 184.2MB 5393ms 47ms kotlin/jvm 17.0.2

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 1169ms 3.6ms 92.6MB 1127ms 50ms dotnet 6.0.401
kotlin 1-m.kt 1354ms 22ms 181.9MB 2107ms 50ms kotlin/jvm 17.0.2