Report compiler performance data to ES

This commit is contained in:
nataliya.valtman
2021-07-28 05:42:15 +03:00
parent 7357aeb1c9
commit 260d301100
20 changed files with 136 additions and 29 deletions
@@ -21,12 +21,11 @@ import org.jetbrains.kotlin.build.GeneratedFile
import org.jetbrains.kotlin.build.report.BuildReporter
import org.jetbrains.kotlin.build.report.metrics.BuildTime
import org.jetbrains.kotlin.build.report.metrics.BuildAttribute
import org.jetbrains.kotlin.build.report.metrics.BuildPerformanceMetric
import org.jetbrains.kotlin.build.report.metrics.measure
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.ExitCode
import org.jetbrains.kotlin.cli.common.*
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.common.toBooleanLenient
import org.jetbrains.kotlin.compilerRunner.MessageCollectorToOutputItemsCollectorAdapter
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl
import org.jetbrains.kotlin.compilerRunner.SimpleOutputItem
@@ -497,5 +496,15 @@ abstract class IncrementalCompilerRunner<
override fun checkCanceled() {
}
}
protected fun reportPerformanceData(defaultPerformanceManager: CommonCompilerPerformanceManager) {
defaultPerformanceManager.getMeasurementResults().forEach {
when (it) {
is CompilerInitializationMeasurement -> reporter.addTimeMetric(BuildTime.COMPILER_INITIALIZATION, it.milliseconds)
is CodeAnalysisMeasurement -> reporter.addTimeMetric(BuildTime.CODE_ANALYSIS, it.milliseconds)
is CodeGenerationMeasurement -> reporter.addTimeMetric(BuildTime.CODE_GENERATION, it.milliseconds)
}
}
}
}
@@ -20,8 +20,9 @@ import org.jetbrains.kotlin.build.GeneratedFile
import org.jetbrains.kotlin.build.report.BuildReporter
import org.jetbrains.kotlin.build.report.ICReporter
import org.jetbrains.kotlin.build.report.metrics.BuildAttribute
import org.jetbrains.kotlin.build.report.metrics.BuildPerformanceMetric
import org.jetbrains.kotlin.build.report.metrics.DoNothingBuildMetricsReporter
import org.jetbrains.kotlin.cli.common.ExitCode
import org.jetbrains.kotlin.cli.common.*
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.isIrBackendEnabled
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
@@ -192,7 +193,8 @@ class IncrementalJsCompilerRunner(
compiler.exec(messageCollector, services, args)
} finally {
args.freeArgs = freeArgsBackup
reporter.report { compiler.defaultPerformanceManager.renderCompilerPerformance() }
// reporter.report { compiler.defaultPerformanceManager.renderCompilerPerformance() }
reportPerformanceData(compiler.defaultPerformanceManager)
}
}
@@ -433,7 +433,8 @@ class IncrementalJvmCompilerRunner(
args.allowNoSourceFiles = true
val exitCode = compiler.exec(messageCollector, services, args)
args.freeArgs = freeArgsBackup
reporter.report { compiler.defaultPerformanceManager.renderCompilerPerformance() }
// reporter.report { compiler.defaultPerformanceManager.renderCompilerPerformance() }
reportPerformanceData(compiler.defaultPerformanceManager)
return exitCode
}
}