Rewrote my Ruby program in Kotlin native, ended up...
# kotlin-native
g
Rewrote my Ruby program in Kotlin native, ended up with a 100 time slower program ... 😕 The parts which make is slower : - spliting a file of 1000 lines, and then spliting each line in 1000 elements - for each on each splited line - trim each string (won 10s by removing that) - getting a value in a collection seems slow too
o
Did you use optimized build? -opt flag
Also if your program runs on JVM using JRuby, it’s not entirely unexpected, as memory allocations optimizations in K/N are not yet merged
g
The Ruby program run in native Ruby, not JVM. What I wanted to show is just how much time it takes compared to another language. I guess Kotlin on JVM would be much faster. I’ll try to port it now, code is short 🙂
So, same code in Kotlin/JVM takes 2.2 seconds instead of 2m45 for Kotlin/native (without -opt flag).
I am looking how to add this flag now
Okay, here is the comparison for exact same code (except IO): Kotlin/Native : real 2m42.136s user 2m40.610s sys 0m0.752s Kotlin/JVM : real 0m0.800s user 0m1.816s sys 0m0.192s
o
Without seeing a program it is hard to make conclusions. What are -opt results?
Note, that without -opt any speed measurements are pretty much useless. Please create an issue on https://github.com/JetBrains/kotlin-native/issues with your code attached, so that we have it for references.
g
it was done with opt on kotlin/native
I’ll attach the projects
o
thanks, we are investigating this problem