Kotlin VS C benchmarks

Current benchmark data was generated on Thu Sep 22 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 635ms 11ms 411.2MB 670ms 73ms kotlin/jvm 17.0.2
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.10

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 129ms 4.6ms 109.4MB 117ms 30ms kotlin/jvm 17.0.2
kotlin 1-m.kt 435ms 7.8ms 30.0MB 717ms 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 2894ms 281ms 161.2MB 5497ms 73ms kotlin/jvm 17.0.2
kotlin 1.kt 2933ms 3.9ms 187.2MB 3770ms 77ms kotlin/jvm 17.0.2
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
kotlin 1-m.kt 709ms 20ms 100.4MB 1243ms 50ms kotlin/jvm 17.0.2
kotlin 2-m.kt 872ms 11ms 32.4MB 1560ms 20ms kotlin/native 1.7.10
kotlin 2-m.kt 996ms 102ms 104.9MB 1797ms 57ms kotlin/jvm 17.0.2
kotlin 1.kt 1082ms 4.7ms 10.7MB 1243ms 0ms kotlin/native 1.7.10

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 2.1ms 0.3ms 1.0MB 0ms 0ms gcc 12.2.0
kotlin 1.kt 2.4ms 0.7ms 1.1MB 0ms 0ms kotlin/native 1.7.10
c 1.c 3.1ms 1.7ms 0.6MB 0ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 1.c 3.1ms 1.3ms 1.1MB 0ms 0ms clang 11.0.0
kotlin 1.kt 65ms 4.3ms 41.0MB 52ms 8ms kotlin/jvm 17.0.2

http-server

Input: 3000

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 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
kotlin 2-m.kt 2345ms 39ms 197.2MB 3470ms 233ms kotlin/jvm 17.0.2
kotlin 1-m.kt 2534ms 62ms 182.6MB 4067ms 260ms 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 1150ms 25ms 207.2MB 1990ms 70ms kotlin/jvm 17.0.2

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1-m.kt 3933ms 75ms 951.0MB 5633ms 287ms kotlin/jvm 17.0.2

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2-m.kt 225ms 3.4ms 113.9MB 340ms 23ms kotlin/jvm 17.0.2
kotlin 1.kt 240ms 2.6ms 109.7MB 297ms 27ms kotlin/jvm 17.0.2
kotlin 2-m.kt 464ms 7.9ms 41.9MB 737ms 10ms kotlin/native 1.7.10
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 371ms 3.0ms 132.6MB 473ms 30ms kotlin/jvm 17.0.2
kotlin 1.kt 457ms 2.5ms 132.8MB 507ms 30ms kotlin/jvm 17.0.2
kotlin 2-m.kt 1412ms 23ms 147.3MB 2163ms 50ms kotlin/native 1.7.10
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
kotlin 1-m.kt 173ms 0.8ms 73.9MB 243ms 17ms kotlin/jvm 17.0.2
kotlin 2-m.kt 177ms 6.2ms 78.8MB 257ms 20ms kotlin/jvm 17.0.2
kotlin 2-m.kt 239ms 3.0ms 29.9MB 400ms 0ms kotlin/native 1.7.10
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 448ms 11ms 356.9MB 457ms 57ms kotlin/jvm 17.0.2
kotlin 1.kt 2377ms 11ms 136.8MB 3457ms 27ms kotlin/native 1.7.10

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 175ms 7.3ms 221.7MB 147ms 53ms kotlin/jvm 17.0.2
kotlin 1.kt 455ms 0.4ms 38.1MB 657ms 3ms kotlin/native 1.7.10

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 308ms 0.1ms 0.5MB 300ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 5.c 321ms 0.7ms 1.0MB 310ms 0ms gcc 12.2.0
c 5.c 329ms 0.5ms 0.6MB 320ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 2.c 338ms 0.3ms 0.6MB 330ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 8-i.c 346ms 3.0ms 1.1MB 333ms 0ms clang 11.0.0
c 5.c 367ms 0.2ms 1.1MB 357ms 0ms clang 11.0.0
c 8-i.c 367ms 3.6ms 1.0MB 353ms 0ms gcc 12.2.0
c 2.c 415ms 7.0ms 1.0MB 397ms 0ms clang 11.0.0
kotlin 1n.kt 549ms 12ms 1.1MB 537ms 0ms kotlin/native 1.7.10
kotlin 1.kt 566ms 1.3ms 43.0MB 577ms 17ms kotlin/jvm 17.0.2
c 2.c 624ms 0.5ms 1.0MB 610ms 0ms gcc 12.2.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 33ms 0.4ms 0.6MB 27ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 5.c 35ms 1.3ms 1.0MB 23ms 0ms gcc 12.2.0
c 5.c 36ms 0.3ms 0.6MB 27ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 2.c 36ms 0.1ms 0.6MB 30ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 8-i.c 39ms 0.4ms 1.0MB 30ms 0ms gcc 12.2.0
c 5.c 40ms 0.6ms 1.1MB 30ms 0ms clang 11.0.0
c 8-i.c 41ms 3.3ms 1.1MB 30ms 0ms clang 11.0.0
c 2.c 43ms 0.2ms 1.1MB 33ms 0ms clang 11.0.0
kotlin 1n.kt 57ms 0.6ms 1.2MB 50ms 0ms kotlin/native 1.7.10
c 2.c 65ms 0.8ms 1.0MB 53ms 0ms gcc 12.2.0
kotlin 1.kt 136ms 3.1ms 42.8MB 143ms 10ms 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.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
kotlin 1.kt 1436ms 7.1ms 244.7MB 1790ms 53ms 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
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
kotlin 1.kt 1072ms 10ms 95.4MB 1477ms 30ms kotlin/jvm 17.0.2
kotlin 1n.kt 4863ms 23ms 75.2MB 6080ms 17ms kotlin/native 1.7.10

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 4510ms 26ms 192.2MB 5413ms 70ms 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 1359ms 7.8ms 183.9MB 2143ms 50ms kotlin/jvm 17.0.2