Kotlin VS Nim benchmarks

Current benchmark data was generated on Mon Oct 03 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 630ms 12ms 413.5MB 673ms 63ms kotlin/jvm 17.0.2
nim 2.nim 3377ms 55ms 34.4MB 3353ms 7ms nim/clang 1.6.8
nim 2.nim 3539ms 69ms 35.1MB 3510ms 13ms nim 1.6.8
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 135ms 16ms 109.6MB 130ms 20ms kotlin/jvm 17.0.2
nim 2.nim 319ms 3.0ms 5.7MB 307ms 0ms nim/clang 1.6.8
nim 2.nim 330ms 0.7ms 5.4MB 317ms 0ms nim 1.6.8
kotlin 1-m.kt 411ms 10ms 42.6MB 653ms 10ms kotlin/native 1.7.20

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2-m.kt 2846ms 155ms 182.7MB 5393ms 60ms kotlin/jvm 17.0.2
kotlin 1.kt 2911ms 11ms 160.2MB 3757ms 57ms kotlin/jvm 17.0.2
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
kotlin 2-m.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
nim 1.nim timeout 0.0ms 0.0MB 0ms 0ms nim 1.6.8
nim 1.nim timeout 0.0ms 0.0MB 0ms 0ms nim/clang 1.6.8

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1-m.kt 717ms 12ms 95.9MB 1253ms 53ms kotlin/jvm 17.0.2
kotlin 2-m.kt 812ms 42ms 36.5MB 1453ms 13ms kotlin/native 1.7.20
kotlin 1.kt 1014ms 7.1ms 8.9MB 1157ms 7ms kotlin/native 1.7.20
kotlin 2-m.kt 1040ms 12ms 105.8MB 1903ms 43ms kotlin/jvm 17.0.2
nim 1.nim timeout 0.0ms 0.0MB 0ms 0ms nim 1.6.8
nim 1.nim timeout 0.0ms 0.0MB 0ms 0ms nim/clang 1.6.8

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 1.6ms 0.4ms 0.7MB 0ms 0ms nim 1.6.8
nim 1.nim 1.9ms 0.7ms 1.0MB 0ms 0ms nim/clang 1.6.8
kotlin 1.kt 3.0ms 0.8ms 1.2MB 0ms 0ms kotlin/native 1.7.20
kotlin 1.kt 66ms 4.9ms 41.0MB 46ms 16ms 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 731ms 2.3ms 94.2MB 330ms 367ms nim 1.6.8
nim 1.nim 735ms 1.5ms 94.3MB 297ms 407ms nim/clang 1.6.8
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
nim 1.nim 123ms 0.9ms 18.3MB 53ms 57ms nim 1.6.8
nim 1.nim 125ms 0.9ms 18.7MB 40ms 67ms nim/clang 1.6.8
kotlin 2-m.kt 2349ms 42ms 198.8MB 3487ms 213ms kotlin/jvm 17.0.2
kotlin 1-m.kt 2488ms 222ms 191.8MB 3967ms 267ms 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 1126ms 3.0ms 206.9MB 1927ms 73ms 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 4215ms 162ms 1116.9MB 6017ms 270ms 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 147ms 0.8ms 1.0MB 140ms 0ms nim/clang 1.6.8
nim 2.nim 158ms 1.3ms 0.7MB 150ms 0ms nim 1.6.8
kotlin 2-m.kt 219ms 2.9ms 113.0MB 323ms 23ms kotlin/jvm 17.0.2
kotlin 1.kt 235ms 1.6ms 109.5MB 293ms 17ms kotlin/jvm 17.0.2
kotlin 2-m.kt 441ms 4.2ms 42.4MB 730ms 3ms kotlin/native 1.7.20
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
nim 1.nim timeout 0.0ms 0.0MB 0ms 0ms nim 1.6.8
nim 1.nim timeout 0.0ms 0.0MB 0ms 0ms nim/clang 1.6.8

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2.kt 365ms 2.6ms 129.5MB 467ms 30ms kotlin/jvm 17.0.2
nim 2.nim 434ms 0.5ms 0.9MB 420ms 0ms nim/clang 1.6.8
kotlin 1.kt 454ms 1.4ms 138.4MB 503ms 30ms kotlin/jvm 17.0.2
nim 2.nim 466ms 0.8ms 0.7MB 457ms 0ms nim 1.6.8
kotlin 2-m.kt 1339ms 41ms 147.6MB 2167ms 47ms kotlin/native 1.7.20
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
nim 1.nim timeout 0.0ms 0.0MB 0ms 0ms nim 1.6.8
nim 1.nim timeout 0.0ms 0.0MB 0ms 0ms nim/clang 1.6.8

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 65ms 0.6ms 1.0MB 53ms 0ms nim/clang 1.6.8
nim 2.nim 68ms 0.9ms 0.6MB 60ms 0ms nim 1.6.8
kotlin 1-m.kt 170ms 0.3ms 75.9MB 247ms 13ms kotlin/jvm 17.0.2
kotlin 2-m.kt 183ms 3.1ms 78.7MB 253ms 27ms kotlin/jvm 17.0.2
kotlin 2-m.kt 229ms 0.3ms 30.3MB 383ms 7ms kotlin/native 1.7.20
nim 1.nim 419ms 6.5ms 1.0MB 407ms 0ms nim/clang 1.6.8
nim 1.nim 448ms 0.6ms 0.7MB 440ms 0ms nim 1.6.8
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 476ms 22ms 560.5MB 433ms 100ms kotlin/jvm 17.0.2
nim 1.nim 1605ms 45ms 34.8MB 1583ms 3ms nim/clang 1.6.8
nim 1.nim 1659ms 3.2ms 35.1MB 1637ms 3ms nim 1.6.8
kotlin 1.kt 2306ms 14ms 138.6MB 3403ms 13ms kotlin/native 1.7.20

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 178ms 3.8ms 221.1MB 160ms 47ms kotlin/jvm 17.0.2
nim 1.nim 340ms 1.1ms 9.9MB 327ms 0ms nim/clang 1.6.8
nim 1.nim 359ms 2.9ms 9.3MB 343ms 0ms nim 1.6.8
kotlin 1.kt 454ms 22ms 38.7MB 653ms 0ms kotlin/native 1.7.20

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 405ms 1.0ms 1.0MB 393ms 0ms nim/clang 1.6.8
nim 2.nim 428ms 0.3ms 1.0MB 413ms 0ms nim 1.6.8
kotlin 1.kt 566ms 1.6ms 42.9MB 580ms 13ms kotlin/jvm 17.0.2
kotlin 1n.kt 577ms 55ms 1.2MB 567ms 0ms kotlin/native 1.7.20

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 46ms 0.7ms 1.0MB 37ms 0ms nim 1.6.8
nim 2.nim 47ms 4.8ms 1.0MB 33ms 0ms nim/clang 1.6.8
kotlin 1n.kt 58ms 0.3ms 1.2MB 50ms 0ms kotlin/native 1.7.20
kotlin 1.kt 136ms 0.9ms 43.1MB 150ms 7ms 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 0.0MB 0ms 0ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
kotlin 2n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
nim 1.nim timeout 0.0ms 0.0MB 0ms 0ms nim 1.6.8
nim 1.nim timeout 0.0ms 0.0MB 0ms 0ms nim/clang 1.6.8

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 1459ms 42ms 205.9MB 1767ms 57ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
kotlin 2n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
nim 1.nim timeout 0.0ms 0.0MB 0ms 0ms nim 1.6.8
nim 1.nim timeout 0.0ms 0.0MB 0ms 0ms nim/clang 1.6.8

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 2569ms 0.7ms 167.2MB 2520ms 30ms nim/clang 1.6.8
nim 1.nim 2574ms 3.7ms 167.2MB 2527ms 33ms nim 1.6.8
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.20

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 265ms 1.4ms 17.0MB 250ms 3ms nim/clang 1.6.8
nim 1.nim 266ms 2.0ms 16.7MB 250ms 3ms nim 1.6.8
kotlin 1.kt 1070ms 13ms 95.0MB 1467ms 30ms kotlin/jvm 17.0.2
kotlin 1n.kt 4349ms 20ms 65.2MB 5673ms 17ms kotlin/native 1.7.20

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 4483ms 33ms 189.8MB 5407ms 53ms 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 1369ms 12ms 191.8MB 2107ms 50ms kotlin/jvm 17.0.2