https://kotlinlang.org logo
Title
j

Javier

12/24/2021, 5:05 PM
I checked that property testing is really slow in KMP compared to JVM. Not sure if this is caused by Kotest or just because KMP tests are slow and property testing is running a lot iterations (probably this last one). Any way to improve it? I tried 100k iterations and it was running under 30 secs in jvm, but in other native target is taking over 2 or 3 minutes
s

sam

12/24/2021, 5:11 PM
The JS runtime is going to be slower than the JVM runtime.
j

Javier

12/24/2021, 5:18 PM
Then the problem is not caused by native, only js?
Interesting
s

sam

12/24/2021, 5:19 PM
Well I'm just guessing. I can't imagine running mocha or karma is faster than the jvm
w

wasyl

12/25/2021, 11:15 AM
Maybe you can try running roughly the same code but in a manual for-loop, with minimal amount of Kotest, and compare the results? That’s how I found some performance issues with the old property testing back couple of months ago (nested `foreach`es with the same code ran much faster than nested `forAll`s)
👀 1
s

sam

12/25/2021, 7:35 PM
Foreach was faster? Because it wasn't creating tests?
w

wasyl

12/25/2021, 8:20 PM
I think it the performance cost was figuring out the test name, it used reflection to read the parameters names in the lambda passed to
forAll
, and they weren’t cached in any way so the cost was paid for each iteration
s

sam

12/25/2021, 8:21 PM
Oh nice spot
I'll create a ticket for that
w

wasyl

12/25/2021, 9:38 PM
Thanks 🙂 I don’t remember why I haven’t reported it back then 🤔 Also I saw some new APIs for those tests that didn’t need reflection?
s

sam

12/25/2021, 9:40 PM
Yep