compileKotlin execution time seems to randomly vary within 2 - 10 second range

I have a Spring Boot + Kotlin + Gradle project and am seeing that the compileKotlin build step takes somewhere between 2 - 10 seconds without any clear reason for the difference in execution time. To test, I’m changing a single string in the response of a REST endpoint and then running the build again. I’ve tried setting:

tasks.compileKotlin {
    kotlinOptions {
        freeCompilerArgs += listOf("-version", "-verbose")
        verbose = true

… but I don’t get any output from the compileKotlin build step.

How can I further investigate what accounts for the difference in execution time?

This came to my mind. Maybe it helps.

Thank you, that looks really helpful. After setting in the, though, I don’t see the report in the expected location ${project_folder}/build/reports/kotlin-build/${project_name}-timestamp.txt

Sorry, had to update my Kotlin plugin versions in the build gradle to 1.7.0. I see the build reports now.

Nothing telling in it though. I diffed two of the output reports and the only difference was the times taken for each step. Eg. Sources compilation round took 1.36 seconds in one build and 1 second in another :thinking: