report GC time
This commit is contained in:
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.utils.KotlinPaths
|
|||||||
import org.jetbrains.kotlin.utils.KotlinPathsFromHomeDir
|
import org.jetbrains.kotlin.utils.KotlinPathsFromHomeDir
|
||||||
import org.jetbrains.kotlin.utils.PathUtil
|
import org.jetbrains.kotlin.utils.PathUtil
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.lang.management.ManagementFactory
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import kotlin.platform.platformStatic
|
import kotlin.platform.platformStatic
|
||||||
|
|
||||||
@@ -189,6 +190,7 @@ public class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (arguments.reportPerf) {
|
if (arguments.reportPerf) {
|
||||||
|
reportGCTime(environment.configuration)
|
||||||
PerformanceCounter.report { s -> reportPerf(environment.configuration, s) }
|
PerformanceCounter.report { s -> reportPerf(environment.configuration, s) }
|
||||||
}
|
}
|
||||||
return OK
|
return OK
|
||||||
@@ -221,6 +223,8 @@ public class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private var initStartNanos = System.nanoTime()
|
private var initStartNanos = System.nanoTime()
|
||||||
|
// allows to track GC time for each run when repeated compilation is used
|
||||||
|
private val elapsedGCTime = hashMapOf<String, Long>()
|
||||||
|
|
||||||
public fun resetInitStartTime() {
|
public fun resetInitStartTime() {
|
||||||
initStartNanos = System.nanoTime()
|
initStartNanos = System.nanoTime()
|
||||||
@@ -235,6 +239,16 @@ public class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
|||||||
collector.report(CompilerMessageSeverity.INFO, "PERF: " + message, CompilerMessageLocation.NO_LOCATION)
|
collector.report(CompilerMessageSeverity.INFO, "PERF: " + message, CompilerMessageLocation.NO_LOCATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun reportGCTime(configuration: CompilerConfiguration) {
|
||||||
|
ManagementFactory.getGarbageCollectorMXBeans().forEach {
|
||||||
|
val currentTime = it.getCollectionTime()
|
||||||
|
val elapsedTime = elapsedGCTime.getOrElse(it.getName()) { 0 }
|
||||||
|
val time = currentTime - elapsedTime
|
||||||
|
reportPerf(configuration, "GC time for ${it.getName()} is $time ms")
|
||||||
|
elapsedGCTime[it.getName()] = currentTime
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun putAdvancedOptions(configuration: CompilerConfiguration, arguments: K2JVMCompilerArguments) {
|
private fun putAdvancedOptions(configuration: CompilerConfiguration, arguments: K2JVMCompilerArguments) {
|
||||||
configuration.put(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, arguments.noCallAssertions)
|
configuration.put(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, arguments.noCallAssertions)
|
||||||
configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, arguments.noParamAssertions)
|
configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, arguments.noParamAssertions)
|
||||||
|
|||||||
Reference in New Issue
Block a user