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