Skip to content

Commit 3b4c08c

Browse files
vsukharevSpace Team
authored andcommitted
[Tests] Add integration test for 1st phase lowerings performance report
^KT-77407
1 parent 8319741 commit 3b4c08c

File tree

1 file changed

+60
-0
lines changed
  • libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle

1 file changed

+60
-0
lines changed

libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BuildReportsIT.kt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,66 @@ class BuildReportsIT : KGPBaseTest() {
855855
}
856856
}
857857

858+
@DisplayName("Verify that the metric for native in-process compilation with IR Inliner on 1st phase")
859+
@NativeGradlePluginTests
860+
@GradleTest
861+
@GradleTestVersions(
862+
additionalVersions = [TestVersions.Gradle.G_8_2],
863+
)
864+
fun testMetricForNativeProjectWithInilnedFunInKlibInProcess(gradleVersion: GradleVersion) {
865+
nativeProject(
866+
"native-incremental-simple", gradleVersion, buildOptions = defaultBuildOptions.copy(
867+
nativeOptions = defaultBuildOptions.nativeOptions.copy(
868+
incremental = true
869+
),
870+
buildReport = listOf(BuildReportType.JSON)
871+
)
872+
) {
873+
buildGradleKts.appendText(
874+
"""
875+
|
876+
|kotlin {
877+
| tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile>().configureEach {
878+
| compilerOptions {
879+
| freeCompilerArgs.add("-XXLanguage:+IrInlinerBeforeKlibSerialization")
880+
| }
881+
| }
882+
|}
883+
""".trimMargin()
884+
)
885+
build("linkDebugExecutableHost", "-Pkotlin.build.report.json.directory=${projectPath.resolve("report").pathString}") {
886+
val jsonReportFile = projectPath.getSingleFileInDir("report")
887+
assertTrue { jsonReportFile.exists() }
888+
val jsonReport = readJsonReport(jsonReportFile)
889+
val bulidTimesKeys = jsonReport.aggregatedMetrics.buildTimes.buildTimesMapMs().keys
890+
assertContains(bulidTimesKeys, GradleBuildTime.NATIVE_IN_PROCESS)
891+
892+
val compilerMetrics = GradleBuildTime.COMPILER_PERFORMANCE.allChildrenMetrics()
893+
val reportedCompilerMetrics = bulidTimesKeys.filter { it in compilerMetrics }
894+
895+
// Recursively (only two levels) gather leaves of subtree under COMPILER_PERFORMANCE, excluding nodes like CODE_GENERATION
896+
val expected = GradleBuildTime.COMPILER_PERFORMANCE.children()?.flatMap { it.children() ?: listOf(it) }
897+
assertEquals(
898+
expected,
899+
reportedCompilerMetrics.sorted()
900+
)
901+
902+
assertEquals(
903+
listOf(
904+
"UpgradeCallableReferences",
905+
"AssertionWrapperLowering",
906+
"AvoidLocalFOsInInlineFunctionsLowering",
907+
"LateinitLowering", // first lowering in K/N 1st phase lowerings, specific for `+IrInlinerBeforeKlibSerialization` feature
908+
),
909+
jsonReport.aggregatedMetrics.buildTimes.dynamicBuildTimesMapMs().keys
910+
.filter { it.parent == GradleBuildTime.IR_PRE_LOWERING }
911+
.map { it.name }
912+
.take(4)
913+
)
914+
}
915+
}
916+
}
917+
858918
companion object {
859919
private const val CAN_NOT_ADD_CUSTOM_VALUES_TO_BUILD_SCAN_MESSAGE = "Can't add any more custom values into build scan"
860920
}

0 commit comments

Comments
 (0)