File tree 3 files changed +13
-4
lines changed
plugin/main/src/kotlinx/benchmark/gradle
3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,9 @@ private fun Project.createAndroidBenchmarkGenerateSourceTask(target: AndroidBenc
104
104
val targetDir = generatedAndroidProjectDir(target, compilation)
105
105
.resolve(" microbenchmark/src/androidTest/kotlin" )
106
106
107
+ if (targetDir.exists()) {
108
+ targetDir.deleteRecursively()
109
+ }
107
110
targetDir.mkdirs()
108
111
109
112
generateBenchmarkSourceFiles(targetDir, classDescriptors)
@@ -193,6 +196,7 @@ private fun captureLogcatOutput() {
193
196
.replace(Regex (" \\ [\\ d+: " ), " [" )
194
197
)
195
198
199
+ line.contains(" Warmup" ) -> println (line.substring(line.indexOf(" Warmup" )))
196
200
line.contains(" Iteration" ) -> println (line.substring(line.indexOf(" Iteration" )))
197
201
line.contains(" run finished" ) -> println (line.substring(line.indexOf(" run finished" )))
198
202
line.contains(" finished" ) -> println ()
Original file line number Diff line number Diff line change @@ -239,15 +239,19 @@ private fun generateCommonMeasurableMethod(
239
239
240
240
methodSpecBuilder
241
241
.addStatement(
242
- " val state = %T(warmupCount = $warmupIterations , repeatCount = $ measurementIterations )" ,
242
+ " val state = %T(repeatCount = ${ warmupIterations + measurementIterations} )" ,
243
243
ClassName (" androidx.benchmark" , " BenchmarkState" )
244
244
)
245
245
.beginControlFlow(" while (state.keepRunning())" )
246
246
.addStatement(" $propertyName .${method.name} ()" )
247
247
.endControlFlow()
248
248
.addStatement(" val measurementResult = state.getMeasurementTimeNs()" )
249
249
.beginControlFlow(" measurementResult.forEachIndexed { index, time ->" )
250
- .addStatement(" Log.d(\" KotlinBenchmark\" , \" Iteration \$ {index + 1}: \$ time ns\" )" )
250
+ .beginControlFlow(" if (index < $warmupIterations )" )
251
+ .addStatement(" Log.d(\" KotlinBenchmark\" , \" Warmup \$ {index + 1}: \$ time ns\" )" )
252
+ .nextControlFlow(" else" )
253
+ .addStatement(" Log.d(\" KotlinBenchmark\" , \" Iteration \$ {index - $warmupIterations + 1}: \$ time ns\" )" )
254
+ .endControlFlow()
251
255
.endControlFlow()
252
256
253
257
typeSpecBuilder.addFunction(methodSpecBuilder.build())
Original file line number Diff line number Diff line change @@ -123,8 +123,9 @@ constructor(
123
123
println (" processConfigurations: AndroidBenchmarkTarget" )
124
124
config.target.compilations.all { compilation ->
125
125
// This block is called for each compilation when they are materialized
126
- println (" handling compilation: $compilation " )
127
- processAndroidCompilation(config, compilation)
126
+ if (compilation.compilationName == " release" ) {
127
+ processAndroidCompilation(config, compilation)
128
+ }
128
129
}
129
130
}
130
131
}
You can’t perform that action at this time.
0 commit comments