Add -Xdump-perf
This commit is contained in:
+7
@@ -153,6 +153,13 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
@Argument(value = "-Xreport-perf", description = "Report detailed performance statistics")
|
||||
var reportPerf: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xdump-perf",
|
||||
valueDescription = "<path>",
|
||||
description = "Dump detailed performance statistics to the specified file"
|
||||
)
|
||||
var dumpPerf: String? by FreezableVar(null)
|
||||
|
||||
open fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
|
||||
return HashMap<AnalysisFlag<*>, Any>().apply {
|
||||
put(AnalysisFlag.skipMetadataVersionCheck, skipMetadataVersionCheck)
|
||||
|
||||
@@ -69,7 +69,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> extends CLI
|
||||
@Override
|
||||
public ExitCode execImpl(@NotNull MessageCollector messageCollector, @NotNull Services services, @NotNull A arguments) {
|
||||
CommonCompilerPerformanceManager performanceManager = getPerformanceManager();
|
||||
if (arguments.getReportPerf()) {
|
||||
if (arguments.getReportPerf() || arguments.getDumpPerf() != null) {
|
||||
performanceManager.enableCollectingPerformanceStatistics();
|
||||
}
|
||||
|
||||
@@ -101,6 +101,10 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> extends CLI
|
||||
);
|
||||
}
|
||||
|
||||
if (arguments.getDumpPerf() != null) {
|
||||
performanceManager.dumpPerformanceReport(new File(arguments.getDumpPerf()));
|
||||
}
|
||||
|
||||
return groupingCollector.hasErrors() ? COMPILATION_ERROR : code;
|
||||
}
|
||||
catch (CompilationCanceledException e) {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.cli.common
|
||||
|
||||
import org.jetbrains.kotlin.util.PerformanceCounter
|
||||
import java.io.File
|
||||
import java.lang.management.ManagementFactory
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@@ -53,6 +54,10 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
|
||||
measurements += CodeGenerationMeasurement(lines, files, TimeUnit.NANOSECONDS.toMillis(time), additionalDescription)
|
||||
}
|
||||
|
||||
fun dumpPerformanceReport(destination: File) {
|
||||
destination.writeBytes(createPerformanceReport())
|
||||
}
|
||||
|
||||
private fun recordGcTime() {
|
||||
if (!isEnabled) return
|
||||
|
||||
@@ -76,4 +81,9 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
|
||||
private fun recordPerfCountersMeasurements() {
|
||||
PerformanceCounter.report { s -> measurements += PerformanceCounterMeasurement(s) }
|
||||
}
|
||||
|
||||
private fun createPerformanceReport(): ByteArray = buildString {
|
||||
appendln("$presentableName performance report")
|
||||
measurements.map { it.render() }.sorted().forEach { appendln(it) }
|
||||
}.toByteArray()
|
||||
}
|
||||
+1
@@ -6,6 +6,7 @@ where advanced options include:
|
||||
-Xallow-kotlin-package Allow compiling code in package 'kotlin' and allow not requiring kotlin.stdlib in module-info
|
||||
-Xcoroutines={enable|warn|error}
|
||||
Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
|
||||
-Xdump-perf=<path> Dump detailed performance statistics to the specified file
|
||||
-Xeffect-system Enable experimental language feature: effect system
|
||||
-Xexperimental=<fq.name> Enable and propagate usages of experimental API for marker annotation with the given fully qualified name
|
||||
-Xintellij-plugin-root=<path> Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found
|
||||
|
||||
+1
@@ -47,6 +47,7 @@ where advanced options include:
|
||||
-Xallow-kotlin-package Allow compiling code in package 'kotlin' and allow not requiring kotlin.stdlib in module-info
|
||||
-Xcoroutines={enable|warn|error}
|
||||
Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
|
||||
-Xdump-perf=<path> Dump detailed performance statistics to the specified file
|
||||
-Xeffect-system Enable experimental language feature: effect system
|
||||
-Xexperimental=<fq.name> Enable and propagate usages of experimental API for marker annotation with the given fully qualified name
|
||||
-Xintellij-plugin-root=<path> Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found
|
||||
|
||||
Reference in New Issue
Block a user