File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
plugin/main/src/kotlinx/benchmark/gradle Expand file tree Collapse file tree 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
104104 val targetDir = generatedAndroidProjectDir(target, compilation)
105105 .resolve(" microbenchmark/src/androidTest/kotlin" )
106106
107+ if (targetDir.exists()) {
108+ targetDir.deleteRecursively()
109+ }
107110 targetDir.mkdirs()
108111
109112 generateBenchmarkSourceFiles(targetDir, classDescriptors)
@@ -193,6 +196,7 @@ private fun captureLogcatOutput() {
193196 .replace(Regex (" \\ [\\ d+: " ), " [" )
194197 )
195198
199+ line.contains(" Warmup" ) -> println (line.substring(line.indexOf(" Warmup" )))
196200 line.contains(" Iteration" ) -> println (line.substring(line.indexOf(" Iteration" )))
197201 line.contains(" run finished" ) -> println (line.substring(line.indexOf(" run finished" )))
198202 line.contains(" finished" ) -> println ()
Original file line number Diff line number Diff line change @@ -239,15 +239,19 @@ private fun generateCommonMeasurableMethod(
239239
240240 methodSpecBuilder
241241 .addStatement(
242- " val state = %T(warmupCount = $warmupIterations , repeatCount = $ measurementIterations )" ,
242+ " val state = %T(repeatCount = ${ warmupIterations + measurementIterations} )" ,
243243 ClassName (" androidx.benchmark" , " BenchmarkState" )
244244 )
245245 .beginControlFlow(" while (state.keepRunning())" )
246246 .addStatement(" $propertyName .${method.name} ()" )
247247 .endControlFlow()
248248 .addStatement(" val measurementResult = state.getMeasurementTimeNs()" )
249249 .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()
251255 .endControlFlow()
252256
253257 typeSpecBuilder.addFunction(methodSpecBuilder.build())
Original file line number Diff line number Diff line change @@ -123,8 +123,9 @@ constructor(
123123 println (" processConfigurations: AndroidBenchmarkTarget" )
124124 config.target.compilations.all { compilation ->
125125 // 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+ }
128129 }
129130 }
130131 }
You can’t perform that action at this time.
0 commit comments