Join Slack
Powered by
what's a good way to quickly bench competing imple...
# getting-started
d
danneu
12/15/2017, 4:45 AM
what's a good way to quickly bench competing implementations of a function? is there something robust but as simple as running each function in a loop + system.getCurrentMillis(), and then doing it a few times to warm up the jvm?
n
nfrankel
12/15/2017, 7:02 AM
there’s a dedicated framework for that on the JVM it’s called JMH
http://openjdk.java.net/projects/code-tools/jmh/
a
andyb
12/15/2017, 11:37 AM
You can also use the inbuilt measureTimeMillis() function to execute the block & return the time taken if you just want something a bit simpler.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.system/measure-time-millis.html
Open in Slack
Previous
Next