Kotlin VS Python 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
python 1.py 1574ms 2.7ms 274.1MB 1453ms 100ms pypy 3.8.13
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.10
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.7
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 120ms 2.4ms 83.3MB 93ms 10ms pypy 3.8.13
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
python 1.py 610ms 3.8ms 11.9MB 583ms 10ms pyston 3.8.12
python 1.py 1514ms 8.6ms 11.8MB 1493ms 3ms cpython 3.10.7

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 1164ms 15ms 196.7MB 1090ms 53ms pypy 3.8.13
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
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.7
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 276ms 1.4ms 95.1MB 237ms 17ms pypy 3.8.13
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
python 1.py 966ms 3.5ms 16.8MB 947ms 3ms pyston 3.8.12
python 1.py 978ms 1.6ms 16.9MB 960ms 0ms cpython 3.10.7
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
kotlin 1.kt 2.4ms 0.7ms 1.1MB 0ms 0ms kotlin/native 1.7.10
python 1.py 13ms 0.7ms 7.3MB 10ms 0ms pyston 3.8.12
python 1.py 15ms 0.3ms 7.3MB 10ms 0ms cpython 3.10.7
python 1.py 34ms 2.4ms 54.0MB 14ms 6ms pypy 3.8.13
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
python 1.py 1563ms 4.8ms 29.1MB 1310ms 903ms pyston 3.8.12
python 1.py 2194ms 14ms 25.2MB 1920ms 1007ms cpython 3.10.7
python 1.py 4362ms 46ms 130.3MB 3430ms 830ms pypy 3.8.13
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
python 1.py 358ms 2.2ms 23.3MB 303ms 147ms pyston 3.8.12
python 1.py 439ms 1.0ms 21.8MB 390ms 160ms cpython 3.10.7
python 1.py 1070ms 9.9ms 105.3MB 870ms 170ms pypy 3.8.13
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
python 1.py 257ms 1.3ms 38.3MB 220ms 17ms pyston 3.8.12
python 1.py 264ms 4.8ms 38.6MB 230ms 17ms cpython 3.10.7
python 1.py 422ms 1.4ms 109.1MB 380ms 27ms pypy 3.8.13
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
python 1.py 2345ms 5.4ms 219.7MB 2230ms 103ms cpython 3.10.7
python 1.py 2387ms 2.0ms 220.5MB 2260ms 110ms pyston 3.8.12
python 1.py 2589ms 8.8ms 248.0MB 2497ms 77ms pypy 3.8.13
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
python 2.py 199ms 0.9ms 80.3MB 170ms 17ms pypy 3.8.13
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
python 1.py 241ms 0.6ms 81.0MB 213ms 13ms pypy 3.8.13
kotlin 2-m.kt 464ms 7.9ms 41.9MB 737ms 10ms kotlin/native 1.7.10
python 1.py 993ms 2.8ms 8.9MB 977ms 0ms pyston 3.8.12
python 2.py 1176ms 4.2ms 8.7MB 1163ms 0ms pyston 3.8.12
python 1.py 1831ms 10ms 8.5MB 1817ms 0ms cpython 3.10.7
python 2.py 2615ms 35ms 8.3MB 2597ms 0ms cpython 3.10.7
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
python 2.py 468ms 4.4ms 80.4MB 443ms 7ms pypy 3.8.13
python 1.py 509ms 2.2ms 81.5MB 477ms 13ms pypy 3.8.13
kotlin 2-m.kt 1412ms 23ms 147.3MB 2163ms 50ms kotlin/native 1.7.10
python 1.py 3011ms 54ms 9.0MB 3000ms 0ms pyston 3.8.12
python 2.py 3482ms 6.9ms 8.7MB 3470ms 0ms pyston 3.8.12
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.10
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.7
python 2.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.7

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 2.py 145ms 1.3ms 80.1MB 117ms 13ms pypy 3.8.13
python 1.py 164ms 3.1ms 81.1MB 140ms 10ms pypy 3.8.13
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
python 1.py 481ms 2.8ms 8.7MB 467ms 0ms pyston 3.8.12
python 2.py 546ms 3.1ms 8.1MB 530ms 0ms pyston 3.8.12
python 1.py 862ms 4.4ms 7.8MB 853ms 0ms cpython 3.10.7
python 2.py 1257ms 5.4ms 7.3MB 1240ms 0ms cpython 3.10.7
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
python 1.py 2434ms 16ms 293.6MB 2253ms 163ms pypy 3.8.13
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.7
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

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
python 1.py 351ms 5.0ms 145.1MB 290ms 40ms pypy 3.8.13
kotlin 1.kt 455ms 0.4ms 38.1MB 657ms 3ms kotlin/native 1.7.10
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.7
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
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
python 2.py 2065ms 46ms 80.0MB 2033ms 13ms pypy 3.8.13
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.7
python 2.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.7
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pypy 3.8.13
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12
python 2.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1n.kt 57ms 0.6ms 1.2MB 50ms 0ms kotlin/native 1.7.10
kotlin 1.kt 136ms 3.1ms 42.8MB 143ms 10ms kotlin/jvm 17.0.2
python 2.py 269ms 5.8ms 79.6MB 237ms 13ms pypy 3.8.13
python 1.py 583ms 7.9ms 79.4MB 560ms 3ms pypy 3.8.13
python 1.py 1184ms 11ms 7.2MB 1167ms 0ms pyston 3.8.12
python 2.py 1613ms 7.5ms 8.1MB 1600ms 0ms pyston 3.8.12
python 1.py 4703ms 56ms 7.4MB 4687ms 0ms cpython 3.10.7
python 2.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.7

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 4.py 2726ms 13ms 119.6MB 2670ms 37ms pypy 3.8.13
python 4.py 2759ms 0.9ms 9.1MB 2723ms 17ms pyston 3.8.12
python 4.py 2767ms 0.5ms 8.6MB 2737ms 17ms cpython 3.10.7
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
python 4.py 653ms 0.8ms 8.8MB 640ms 0ms pyston 3.8.12
python 4.py 660ms 0.3ms 8.3MB 647ms 0ms cpython 3.10.7
python 4.py 684ms 5.3ms 84.5MB 657ms 10ms pypy 3.8.13
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
python 1.py 3326ms 0.7ms 265.3MB 3237ms 70ms pypy 3.8.13
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
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.7
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 465ms 2.9ms 103.5MB 423ms 23ms pypy 3.8.13
python 1.py 699ms 3.7ms 30.3MB 653ms 20ms pyston 3.8.12
python 1.py 847ms 1.1ms 31.0MB 817ms 17ms cpython 3.10.7
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
python 1.py 4528ms 9.5ms 8.3MB 4513ms 0ms pyston 3.8.12
python 1.py 4900ms 14ms 87.1MB 4867ms 17ms pypy 3.8.13
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.10.7

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 1144ms 1.3ms 8.4MB 1130ms 0ms pyston 3.8.12
kotlin 1-m.kt 1359ms 7.8ms 183.9MB 2143ms 50ms kotlin/jvm 17.0.2
python 1.py 1375ms 6.1ms 84.2MB 1343ms 13ms pypy 3.8.13
python 1.py 1498ms 22ms 7.3MB 1480ms 0ms cpython 3.10.7