Kotlin TestImplementation slowing down execution by 25%

I have a little program calculating on a np-hard problem, so the most execution time is generated in math calculations.

I never took much attention to the “testImplementation(“org.jetbrains.kotlin:kotlin-test-junit:1.9.0”)” part in the gradle file, as I do not use that functionality.

However, after I upgraded from version 1.6.20 to 1.9 there was a drop in calculation time of about 25%. I downgraded and upgraded several times with always the same result. I now took it out and are even a tiny bit faster.

I was of the opinion, this will not have an impact, or at least not in the non-debug version?

Any thoughts?

Update: This is difficult. Apparently, only the first compile gets the high speed, even a recompile results in slower execution speed. TestImplementation does not make a difference, other that when including apparently the first compilation is also slow.

Very hard to reproduce, sometimes better speed after clearing cache.

I don’t have an answer — but the next place I’d look would be the bytecode. Can you take a copy of the relevant .class file(s) from a ‘fast’ version and a ‘slow’ version, decompile them, and compare?

How do you test the speed? How do you run it, how do you measure? What’s the average fast and slow time?

1 Like