I benchmarked kotlin rust and go. The results will shock you , or not.

Here are somes benchmarks to compare Kotlin, Rust and Go. The winner is Rust as we could expect but it is interesting to see by how much. The real suspense was for the second place.

Here is the description of the different benchmarks. Json matters since it is common to see a server spend a majority of its time in serialization/deserialization. There is also 5 different types of loops, to explore what happens with auto vectorization, branching and complexity.

  • json-ser: Json serialization
  • json-deser: Json deserialization
  • itoa: Converting integers to strings
  • nonVectoLoop: A loop that cannot get Loop Unrolling, or use simd instructions.
  • branchingNonVectoLoop: Same as nonVectoLoop but with branching.
  • trivialAutoVectoLoop: Adding an array of numbers.
  • complexAutoVectoLoop: Similar to trivialAutoVectoLoop but with more arithmetic ops.
  • branchingAutoVectoLoop: Similar to trivialAutoVectoLoop but with branching.

Here are the results for 11th Gen Intel(R) Core(TM) i5-1135G7.

Benchmark Summary (Smaller percentage is better) (Ignored 2 warmups) (effort=200) json-ser scale: 772ms rust-serde mean: 16%, meanDiff: 0% kotlin-jvm-jsoniter mean: 91%, meanDiff: 4% go-jsoniter mean:100%, meanDiff: 3% json-deser scale: 1628ms rust-serde mean: 44%, meanDiff: 1% kotlin-jvm-jsoniter mean: 49%, meanDiff: 2% go-jsoniter mean:100%, meanDiff: 2% itoa scale: 5438ms rust mean: 30%, meanDiff: 1% kotlin-jvm-heapless mean: 45%, meanDiff: 1% kotlin-jvm mean: 51%, meanDiff: 2% go mean:100%, meanDiff: 2% nonVectoLoop scale: 694ms kotlin-jvm mean: 87%, meanDiff: 3% go mean: 94%, meanDiff: 1% rust mean:100%, meanDiff: 2% branchingNonVectoLoop scale: 1031ms rust mean: 58%, meanDiff: 0% kotlin-jvm mean: 76%, meanDiff: 13% go mean:100%, meanDiff: 1% complexAutoVectoLoop scale: 384ms rust mean: 67%, meanDiff: 2% kotlin-jvm mean: 92%, meanDiff: 5% go mean:100%, meanDiff: 2% trivialAutoVectoLoop scale: 7585ms rust mean: 9%, meanDiff: 0% kotlin-jvm mean: 35%, meanDiff: 1% go mean:100%, meanDiff: 1% branchingAutoVectoLoop scale: 7038ms rust mean: 11%, meanDiff: 0% go mean: 83%, meanDiff: 2% kotlin-jvm mean:100%, meanDiff: 1% 

Here is the repo

https://github.com/simon1514/lang_bench

submitted by /u/Inevitable-Edge4305
[link] [comments]