Kotlin VS Nim 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
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
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
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
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
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
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
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
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

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
kotlin 1.kt 2.6ms 0.4ms 1.5MB 0ms 0ms kotlin/native 1.8.10
kotlin 1.kt 78ms 1.3ms 40.7MB 62ms 10ms kotlin/jvm 17.0.2

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
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
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
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
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
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
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
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
kotlin 1.kt timeout 0.0ms 15.0MB 5003ms 7ms kotlin/native 1.8.10
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
kotlin 2.kt 497ms 17ms 130.5MB 600ms 57ms kotlin/jvm 17.0.2
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
kotlin 1.kt 592ms 9.7ms 132.2MB 643ms 43ms kotlin/jvm 17.0.2
kotlin 2-m.kt 1648ms 11ms 114.0MB 2420ms 93ms kotlin/native 1.8.10
kotlin 1.kt timeout 0.0ms 15.0MB 4997ms 10ms kotlin/native 1.8.10
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
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
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
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
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
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
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
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
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
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

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
kotlin 1n.kt 88ms 3.6ms 1.5MB 80ms 0ms kotlin/native 1.8.10
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
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
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

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
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
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
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
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
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
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
kotlin 1-m.kt 1604ms 20ms 182.9MB 2433ms 83ms kotlin/jvm 17.0.2