Skip to content

Commit a06a440

Browse files
committed
rebase
1 parent 883d556 commit a06a440

File tree

4 files changed

+22
-173
lines changed

4 files changed

+22
-173
lines changed

core/src/main/kotlin/com/tschuchort/compiletesting/HostClasspaths.kt

-114
This file was deleted.

profiling/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ buildscript {
55
dependencies {
66
testImplementation project(':core')
77
testImplementation project(':ksp')
8+
testImplementation "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"
89
testImplementation "com.google.devtools.ksp:symbol-processing-api:$ksp_version"
910
}

profiling/src/test/kotlin/com/tschuchort/compiletesting/ProfilingTest.kt

+16-31
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import com.google.devtools.ksp.processing.CodeGenerator
44
import com.google.devtools.ksp.processing.KSPLogger
55
import com.google.devtools.ksp.processing.Resolver
66
import com.google.devtools.ksp.processing.SymbolProcessor
7+
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
8+
import org.junit.Before
79
import org.junit.ClassRule
810
import org.junit.Rule
911
import org.junit.Test
@@ -30,13 +32,20 @@ class ProfilingTest(
3032
}
3133
}
3234

35+
@Before
36+
fun setCompilerCache() {
37+
val existingValue:String? = System.getProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY)
38+
System.setProperty(
39+
KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY,
40+
if (testConfiguration.useCachedCompilerEnv) "true" else "false"
41+
)
42+
}
43+
3344
private fun newKotlinCompilation() = KotlinCompilation().apply {
3445
when (testConfiguration.processorType) {
3546
ProcessorType.KAPT -> annotationProcessors = listOf(DoNothingKapt())
3647
ProcessorType.KSP -> symbolProcessors = listOf(DonothingKsp())
3748
}
38-
useCachedHostClasspath = testConfiguration.enableClasspathCache
39-
useMyClasspath = testConfiguration.useGoogleCompileTestingClasspath
4049
verbose = false
4150
}
4251

@@ -109,24 +118,9 @@ class ProfilingTest(
109118

110119
data class TestConfiguration(
111120
val processorType: ProcessorType,
112-
val enableClasspathCache: Boolean,
113-
val useGoogleCompileTestingClasspath: Boolean,
121+
val useCachedCompilerEnv: Boolean
114122
) {
115-
companion object {
116-
fun buildVariations(): List<TestConfiguration> {
117-
return ProcessorType.values().flatMap { processorType ->
118-
arrayOf(true, false).flatMap { enableClasspathCache ->
119-
arrayOf(true, false).map { useGoogleCompileTestingClasspath ->
120-
TestConfiguration(
121-
processorType = processorType,
122-
enableClasspathCache = enableClasspathCache,
123-
useGoogleCompileTestingClasspath = useGoogleCompileTestingClasspath
124-
)
125-
}
126-
}
127-
}
128-
}
129-
}
123+
130124
}
131125

132126
companion object {
@@ -136,20 +130,11 @@ class ProfilingTest(
136130
listOf(
137131
TestConfiguration(
138132
processorType = ProcessorType.KAPT,
139-
enableClasspathCache = true,
140-
useGoogleCompileTestingClasspath = false
141-
),
142-
TestConfiguration(
143-
processorType = ProcessorType.KAPT,
144-
enableClasspathCache = false,
145-
useGoogleCompileTestingClasspath = false
146-
),
147-
TestConfiguration(
148-
processorType = ProcessorType.KAPT,
149-
enableClasspathCache = false,
150-
useGoogleCompileTestingClasspath = true
133+
useCachedCompilerEnv = false
151134
)
152135
)
136+
}.flatMap {
137+
listOf(it, it.copy(useCachedCompilerEnv = true))
153138
}
154139

155140
@get:ClassRule

profiling/src/test/kotlin/com/tschuchort/compiletesting/TimeTracking.kt

+5-28
Original file line numberDiff line numberDiff line change
@@ -53,33 +53,12 @@ class TimeTracking : TestRule {
5353
measurements: Map<ProfilingTest.TestConfiguration, List<Long>>
5454
) {
5555
System.err.println("report for $testName")
56-
System.err.println("use Google true:")
57-
58-
val groupedBy_enableClasspathCache = measurements.entries.groupBy {
59-
it.key.enableClasspathCache
60-
}
61-
groupedBy_enableClasspathCache.entries.forEach { (key, value) ->
62-
value.flatMap { it.value }.groupBy {
63-
it
64-
}
65-
}
66-
67-
measurements.entries.filter {
68-
it.key.useGoogleCompileTestingClasspath
69-
}.groupBy {
70-
it.key
71-
}.forEach {
72-
val analysis = analyze(it.value.flatMap { it.value }.removeOutliers())
73-
System.err.println("${it.key}: ${analysis.toString()}")
74-
}
75-
System.err.println("use Google false:")
76-
measurements.entries.filter {
77-
!it.key.useGoogleCompileTestingClasspath
78-
}.groupBy {
79-
it.key
56+
measurements.mapValues {
57+
analyze(it.value.removeOutliers())
58+
}.entries.sortedBy {
59+
it.value.avg
8060
}.forEach {
81-
val analysis = analyze(it.value.flatMap { it.value }.removeOutliers())
82-
System.err.println("${it.key}: ${analysis.toString()}")
61+
System.err.println("${it.key} (${it.value.avg}) : ${it.value}")
8362
}
8463
}
8564

@@ -123,15 +102,13 @@ class TimeTracking : TestRule {
123102
sources = listOf(SourceFile.kotlin("Foo.kt", ""))
124103
annotationProcessors = listOf(ProfilingTest.DoNothingKapt())
125104
symbolProcessors = listOf(ProfilingTest.DonothingKsp())
126-
useCachedHostClasspath = true
127105
}.compile()
128106
}
129107
repeat(2) {
130108
KotlinCompilation().apply {
131109
sources = listOf(SourceFile.kotlin("Foo.kt", ""))
132110
annotationProcessors = listOf(ProfilingTest.DoNothingKapt())
133111
symbolProcessors = listOf(ProfilingTest.DonothingKsp())
134-
useMyClasspath = true
135112
}.compile()
136113
}
137114
}

0 commit comments

Comments
 (0)