Disable performance time counters by default
This commit is contained in:
@@ -61,6 +61,7 @@ public open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
PathUtil.getKotlinPathsForCompiler()
|
||||
|
||||
messageSeverityCollector.report(CompilerMessageSeverity.LOGGING, "Using Kotlin home directory " + paths.getHomePath(), CompilerMessageLocation.NO_LOCATION)
|
||||
PerformanceCounter.setTimeCounterEnabled(arguments.reportPerf);
|
||||
|
||||
val configuration = CompilerConfiguration()
|
||||
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageSeverityCollector)
|
||||
|
||||
@@ -26,6 +26,8 @@ public class PerformanceCounter jvmOverloads constructor (val name: String, val
|
||||
|
||||
private val enteredCounters = ThreadLocal<MutableSet<PerformanceCounter>>()
|
||||
|
||||
private var enabled = false
|
||||
|
||||
init {
|
||||
threadMxBean.setThreadCpuTimeEnabled(true)
|
||||
}
|
||||
@@ -52,6 +54,10 @@ public class PerformanceCounter jvmOverloads constructor (val name: String, val
|
||||
}
|
||||
countersCopy.forEach { it.report(consumer) }
|
||||
}
|
||||
|
||||
public fun setTimeCounterEnabled(enable: Boolean) {
|
||||
enabled = enable
|
||||
}
|
||||
}
|
||||
|
||||
private var count: Int = 0
|
||||
@@ -69,6 +75,8 @@ public class PerformanceCounter jvmOverloads constructor (val name: String, val
|
||||
|
||||
public fun time<T>(block: () -> T): T {
|
||||
count++
|
||||
if (!enabled) return block()
|
||||
|
||||
val needTime = !reenterable || enterCounter(this)
|
||||
val startTime = currentThreadCpuTime()
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user