Kotlin VS Wasm benchmarks

Current benchmark data was generated on Wed May 25 2022, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8272CL 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 712ms 0.5ms 307.9MB 740ms 87ms kotlin/jvm 17.0.2
wasm 5.rs 1898ms 17ms 24.9MB 1873ms 7ms wasmedgec 0.9.1
wasm 5.rs 1936ms 34ms 22.0MB 1907ms 13ms wasmer/llvm 2.2.1
wasm 3.rs 2021ms 18ms 38.4MB 1977ms 30ms wasmer/llvm 2.2.1
wasm 4.rs 2088ms 133ms 22.1MB 2067ms 7ms wasmer/llvm 2.2.1
wasm 4.rs 2092ms 26ms 25.0MB 2073ms 0ms wasmedgec 0.9.1
wasm 3.rs 2156ms 149ms 40.9MB 2127ms 17ms wasmedgec 0.9.1
wasm 5.rs 2608ms 151ms 57.6MB 2600ms 17ms node 16.15.0
wasm 3.rs 2647ms 167ms 73.5MB 2627ms 30ms node 16.15.0
wasm 4.rs 2785ms 64ms 57.4MB 2780ms 13ms node 16.15.0
wasm 5.rs 2799ms 19ms 26.1MB 2777ms 7ms wasmtime 0.37.0
wasm 3.rs 2904ms 27ms 42.0MB 2873ms 10ms wasmtime 0.37.0
wasm 4.rs 2950ms 7.6ms 26.0MB 2930ms 3ms wasmtime 0.37.0
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.6.21

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 137ms 1.9ms 109.6MB 113ms 33ms kotlin/jvm 17.0.2
wasm 5.rs 188ms 5.7ms 10.9MB 177ms 0ms wasmedgec 0.9.1
wasm 3.rs 193ms 13ms 10.2MB 167ms 3ms wasmer/llvm 2.2.1
wasm 4.rs 194ms 11ms 8.3MB 173ms 0ms wasmer/llvm 2.2.1
wasm 4.rs 203ms 1.7ms 11.0MB 183ms 0ms wasmedgec 0.9.1
wasm 5.rs 215ms 14ms 8.2MB 193ms 0ms wasmer/llvm 2.2.1
wasm 3.rs 218ms 7.1ms 12.9MB 197ms 3ms wasmedgec 0.9.1
wasm 5.rs 255ms 17ms 12.1MB 240ms 0ms wasmtime 0.37.0
wasm 3.rs 278ms 22ms 14.2MB 250ms 3ms wasmtime 0.37.0
wasm 4.rs 280ms 0.6ms 12.1MB 263ms 0ms wasmtime 0.37.0
wasm 5.rs 300ms 21ms 43.2MB 300ms 10ms node 16.15.0
wasm 4.rs 331ms 4.6ms 43.6MB 343ms 3ms node 16.15.0
wasm 3.rs 355ms 50ms 45.7MB 337ms 10ms node 16.15.0
kotlin 1.kt 380ms 1.3ms 62.1MB 350ms 13ms kotlin/native 1.6.21

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
wasm 3.rs 1151ms 3.4ms 8.2MB 1143ms 0ms wasmer/llvm 2.2.1
wasm 3.rs 1391ms 99ms 47.1MB 1430ms 7ms node 16.15.0
wasm 3.rs 1617ms 11ms 12.0MB 1607ms 0ms wasmtime 0.37.0
kotlin 2-m.kt 3070ms 596ms 182.5MB 5807ms 87ms kotlin/jvm 17.0.2
kotlin 1.kt 3092ms 4.3ms 170.9MB 3890ms 70ms kotlin/jvm 17.0.2
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.6.21
kotlin 2-m.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.6.21

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
wasm 3.rs 81ms 13ms 6.9MB 67ms 0ms wasmer/llvm 2.2.1
wasm 3.rs 103ms 7.1ms 10.7MB 90ms 0ms wasmtime 0.37.0
wasm 3.rs 213ms 2.3ms 47.4MB 253ms 13ms node 16.15.0
kotlin 1-m.kt 706ms 27ms 93.2MB 1247ms 43ms kotlin/jvm 17.0.2
kotlin 2-m.kt 976ms 5.7ms 68.2MB 1703ms 33ms kotlin/native 1.6.21
kotlin 2-m.kt 1003ms 75ms 105.5MB 1820ms 40ms kotlin/jvm 17.0.2
kotlin 1.kt 1172ms 4.8ms 48.7MB 1147ms 10ms kotlin/native 1.6.21

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 2.6ms 0.9ms 1.2MB 0ms 0ms kotlin/native 1.6.21
wasm 1.rs 5.8ms 1.2ms 9.0MB 0ms 0ms wasmtime 0.37.0
wasm 1.rs 7.6ms 9.4ms 5.9MB 0ms 0ms wasmer/llvm 2.2.1
wasm 1.rs 10ms 0.6ms 8.5MB 0ms 0ms wasmedgec 0.9.1
kotlin 1.kt 73ms 2.6ms 41.1MB 52ms 12ms kotlin/jvm 17.0.2
wasm 1.rs 76ms 1.6ms 41.6MB 82ms 12ms node 16.15.0

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 2250ms 240ms 237.8MB 3337ms 303ms kotlin/jvm 17.0.2
kotlin 1-m.kt 2284ms 167ms 236.0MB 3647ms 287ms 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 1042ms 27ms 215.1MB 1737ms 83ms 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 4142ms 313ms 954.1MB 5743ms 387ms kotlin/jvm 17.0.2

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
wasm 1.rs 123ms 2.1ms 6.3MB 107ms 0ms wasmer/llvm 2.2.1
wasm 1.rs 129ms 9.2ms 10.9MB 117ms 0ms wasmtime 0.37.0
wasm 1.rs 141ms 0.5ms 9.2MB 130ms 0ms wasmedgec 0.9.1
wasm 1.rs 222ms 4.3ms 45.8MB 237ms 7ms node 16.15.0
kotlin 2-m.kt 243ms 1.3ms 112.3MB 323ms 47ms kotlin/jvm 17.0.2
kotlin 1.kt 256ms 2.6ms 109.7MB 307ms 33ms kotlin/jvm 17.0.2
kotlin 2.kt 395ms 25ms 92.1MB 363ms 13ms kotlin/native 1.6.21
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.6.21

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
wasm 1.rs 356ms 1.5ms 6.2MB 340ms 0ms wasmer/llvm 2.2.1
wasm 1.rs 386ms 27ms 10.2MB 373ms 0ms wasmtime 0.37.0
wasm 1.rs 394ms 4.9ms 11.2MB 380ms 0ms wasmedgec 0.9.1
kotlin 2.kt 417ms 7.8ms 127.4MB 510ms 47ms kotlin/jvm 17.0.2
kotlin 1.kt 484ms 10.0ms 138.4MB 517ms 53ms kotlin/jvm 17.0.2
wasm 1.rs 489ms 7.3ms 42.4MB 500ms 10ms node 16.15.0
kotlin 2.kt 1335ms 16ms 150.2MB 1290ms 30ms kotlin/native 1.6.21
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.6.21

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
wasm 1.rs 68ms 5.3ms 9.1MB 57ms 0ms wasmtime 0.37.0
wasm 1.rs 69ms 13ms 5.7MB 53ms 0ms wasmer/llvm 2.2.1
wasm 1.rs 77ms 2.6ms 9.2MB 70ms 0ms wasmedgec 0.9.1
wasm 1.rs 152ms 3.7ms 42.6MB 167ms 3ms node 16.15.0
kotlin 1.kt 184ms 1.5ms 74.1MB 240ms 27ms kotlin/jvm 17.0.2
kotlin 2.kt 192ms 3.8ms 42.1MB 167ms 10ms kotlin/native 1.6.21
kotlin 2-m.kt 199ms 1.9ms 78.8MB 280ms 30ms kotlin/jvm 17.0.2
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.6.21

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 538ms 9.7ms 363.9MB 503ms 113ms kotlin/jvm 17.0.2
wasm 1.rs 1014ms 67ms 30.1MB 977ms 20ms wasmer/llvm 2.2.1
wasm 1.rs 1086ms 70ms 32.9MB 1063ms 7ms wasmedgec 0.9.1
wasm 1.rs 1390ms 16ms 66.1MB 1380ms 23ms node 16.15.0
wasm 1.rs 1431ms 13ms 34.1MB 1403ms 10ms wasmtime 0.37.0
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.6.21

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 203ms 1.8ms 221.2MB 180ms 57ms kotlin/jvm 17.0.2
wasm 1.rs 220ms 29ms 12.2MB 193ms 7ms wasmer/llvm 2.2.1
wasm 1.rs 225ms 0.4ms 16.9MB 210ms 0ms wasmedgec 0.9.1
wasm 1.rs 307ms 1.7ms 16.0MB 290ms 0ms wasmtime 0.37.0
wasm 1.rs 356ms 5.1ms 47.8MB 353ms 10ms node 16.15.0
kotlin 1.kt 689ms 9.9ms 74.3MB 657ms 10ms kotlin/native 1.6.21

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
wasm 1.rs 545ms 0.1ms 4.9MB 533ms 0ms wasmer/llvm 2.2.1
wasm 1.rs 558ms 19ms 9.3MB 547ms 0ms wasmtime 0.37.0
wasm 1.rs 609ms 0.4ms 9.2MB 597ms 0ms wasmedgec 0.9.1
kotlin 1.kt 633ms 16ms 43.1MB 647ms 10ms kotlin/jvm 17.0.2
wasm 1.rs 644ms 12ms 46.4MB 657ms 10ms node 16.15.0
kotlin 1n.kt 705ms 4.2ms 1.1MB 693ms 0ms kotlin/native 1.6.21
wasm 2.rs 729ms 68ms 9.6MB 713ms 0ms wasmedgec 0.9.1
wasm 2.rs 780ms 43ms 5.1MB 773ms 0ms wasmer/llvm 2.2.1
wasm 2.rs 824ms 30ms 11.0MB 810ms 0ms wasmtime 0.37.0
wasm 2.rs 891ms 2.3ms 46.4MB 907ms 7ms node 16.15.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
wasm 1.rs 61ms 11ms 5.9MB 50ms 0ms wasmer/llvm 2.2.1
wasm 1.rs 65ms 1.4ms 9.2MB 53ms 0ms wasmtime 0.37.0
kotlin 1n.kt 73ms 1.5ms 1.1MB 67ms 0ms kotlin/native 1.6.21
wasm 1.rs 74ms 1.8ms 9.2MB 60ms 0ms wasmedgec 0.9.1
wasm 2.rs 90ms 16ms 5.8MB 67ms 0ms wasmer/llvm 2.2.1
wasm 2.rs 92ms 1.5ms 9.6MB 77ms 0ms wasmedgec 0.9.1
wasm 2.rs 93ms 1.5ms 10.9MB 80ms 0ms wasmtime 0.37.0
kotlin 1.kt 149ms 1.4ms 43.2MB 160ms 17ms kotlin/jvm 17.0.2
wasm 1.rs 157ms 4.8ms 46.4MB 170ms 10ms node 16.15.0
wasm 2.rs 180ms 4.3ms 46.4MB 200ms 7ms node 16.15.0

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
wasm 2.rs 2831ms 209ms 7.0MB 2820ms 0ms wasmer/llvm 2.2.1
wasm 2.rs 3027ms 2.2ms 10.9MB 3010ms 3ms wasmedgec 0.9.1
wasm 2.rs 3488ms 245ms 10.7MB 3477ms 0ms wasmtime 0.37.0
wasm 2.rs 3816ms 4.7ms 46.2MB 3850ms 13ms node 16.15.0
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.6.21
kotlin 2n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.6.21

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
wasm 2.rs 702ms 55ms 6.4MB 683ms 0ms wasmer/llvm 2.2.1
wasm 2.rs 727ms 3.7ms 10.6MB 713ms 0ms wasmedgec 0.9.1
wasm 2.rs 862ms 2.4ms 11.3MB 843ms 0ms wasmtime 0.37.0
wasm 2.rs 990ms 5.2ms 46.3MB 1027ms 13ms node 16.15.0
kotlin 1.kt 1560ms 32ms 249.6MB 1917ms 100ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.6.21
kotlin 2n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.6.21

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
wasm 0.rs 364ms 40ms 9.8MB 350ms 0ms wasmedgec 0.9.1
wasm 0.rs 394ms 22ms 4.9MB 380ms 0ms wasmer/llvm 2.2.1
wasm 0.rs 449ms 23ms 45.2MB 463ms 10ms node 16.15.0
wasm 0.rs 453ms 0.5ms 10.3MB 440ms 0ms wasmtime 0.37.0
wasm 1.rs 3885ms 281ms 10.3MB 3877ms 0ms wasmedgec 0.9.1
wasm 1.rs 4057ms 287ms 5.0MB 4043ms 0ms wasmer/llvm 2.2.1
kotlin 1.kt 4437ms 132ms 187.6MB 5327ms 63ms kotlin/jvm 17.0.2
wasm 1.rs 4685ms 30ms 51.0MB 4727ms 10ms node 16.15.0
wasm 1.rs timeout 0.0ms 0.0MB 0ms 0ms wasmtime 0.37.0

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
wasm 0.rs 97ms 1.9ms 9.8MB 83ms 0ms wasmedgec 0.9.1
wasm 0.rs 109ms 4.9ms 5.7MB 93ms 0ms wasmer/llvm 2.2.1
wasm 0.rs 121ms 0.7ms 9.5MB 110ms 0ms wasmtime 0.37.0
wasm 0.rs 184ms 6.4ms 45.3MB 203ms 7ms node 16.15.0
wasm 1.rs 943ms 3.5ms 10.4MB 923ms 0ms wasmedgec 0.9.1
wasm 1.rs 991ms 68ms 5.7MB 970ms 0ms wasmer/llvm 2.2.1
wasm 1.rs 1267ms 3.5ms 9.8MB 1250ms 0ms wasmtime 0.37.0
wasm 1.rs 1271ms 7.8ms 50.6MB 1303ms 20ms node 16.15.0
kotlin 1-m.kt 1370ms 11ms 193.2MB 2130ms 77ms kotlin/jvm 17.0.2