diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index ee4b3601149..580264eab08 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -191,6 +191,7 @@ public class K2JVMCompiler : CLICompiler() { if (arguments.reportPerf) { reportGCTime(environment.configuration) + reportCompilationTime(environment.configuration) PerformanceCounter.report { s -> reportPerf(environment.configuration, s) } } return OK @@ -225,6 +226,7 @@ public class K2JVMCompiler : CLICompiler() { private var initStartNanos = System.nanoTime() // allows to track GC time for each run when repeated compilation is used private val elapsedGCTime = hashMapOf() + private var elapsedJITTime = 0L public fun resetInitStartTime() { initStartNanos = System.nanoTime() @@ -249,6 +251,13 @@ public class K2JVMCompiler : CLICompiler() { } } + fun reportCompilationTime(configuration: CompilerConfiguration) { + val bean = ManagementFactory.getCompilationMXBean() ?: return + val currentTime = bean.getTotalCompilationTime() + reportPerf(configuration, "JIT time is ${currentTime - elapsedJITTime} ms") + elapsedJITTime = currentTime + } + private fun putAdvancedOptions(configuration: CompilerConfiguration, arguments: K2JVMCompilerArguments) { configuration.put(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, arguments.noCallAssertions) configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, arguments.noParamAssertions)