Move JUnit4 usage to separate module
Fixes: 138451391
Test: ./gradlew bench:b-c:cC bench:b-j:cC bench:b-b:cC
Test: ./gradlew compose:compose-runtime-benchmark:assembleDebug
This enables us to implement alternate APIs on top of BenchmarkState
in the future.
Change-Id: I91b8260c06baf58411286391345a0603d94781d9
diff --git a/appcompat/benchmark/build.gradle b/appcompat/benchmark/build.gradle
index ee2dcf4..8ff9b65 100644
--- a/appcompat/benchmark/build.gradle
+++ b/appcompat/benchmark/build.gradle
@@ -25,7 +25,7 @@
dependencies {
androidTestImplementation(project(":appcompat"))
- androidTestImplementation(project(":benchmark:benchmark-common"))
+ androidTestImplementation(project(":benchmark:benchmark-junit4"))
androidTestImplementation(ANDROIDX_TEST_EXT_JUNIT)
androidTestImplementation(ANDROIDX_TEST_CORE)
androidTestImplementation(ANDROIDX_TEST_RUNNER)
diff --git a/appcompat/benchmark/src/androidTest/java/androidx/appcompat/benchmark/ViewInflationBenchmark.kt b/appcompat/benchmark/src/androidTest/java/androidx/appcompat/benchmark/ViewInflationBenchmark.kt
index 7976411..9817973 100644
--- a/appcompat/benchmark/src/androidTest/java/androidx/appcompat/benchmark/ViewInflationBenchmark.kt
+++ b/appcompat/benchmark/src/androidTest/java/androidx/appcompat/benchmark/ViewInflationBenchmark.kt
@@ -21,8 +21,8 @@
import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.benchmark.test.R
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
+import androidx.benchmark.junit4.BenchmarkRule
+import androidx.benchmark.junit4.measureRepeated
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.rule.ActivityTestRule
diff --git a/benchmark/benchmark/build.gradle b/benchmark/benchmark/build.gradle
index 9f6d151..23f8633 100644
--- a/benchmark/benchmark/build.gradle
+++ b/benchmark/benchmark/build.gradle
@@ -22,7 +22,7 @@
}
dependencies {
- androidTestImplementation(project(":benchmark:benchmark-common"))
+ androidTestImplementation(project(":benchmark:benchmark-junit4"))
androidTestImplementation(ANDROIDX_TEST_RUNNER)
androidTestImplementation(ANDROIDX_TEST_RULES)
androidTestImplementation(JUNIT)
diff --git a/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/ParameterizedBenchmark.kt b/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/ParameterizedBenchmark.kt
index 214aea1..050c32d 100644
--- a/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/ParameterizedBenchmark.kt
+++ b/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/ParameterizedBenchmark.kt
@@ -16,8 +16,8 @@
package androidx.benchmark.benchmark
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
+import androidx.benchmark.junit4.BenchmarkRule
+import androidx.benchmark.junit4.measureRepeated
import androidx.test.filters.LargeTest
import org.junit.Rule
import org.junit.Test
diff --git a/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/SynchronizedBenchmark.kt b/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/SynchronizedBenchmark.kt
index 5cadaf8..4dcaa59 100644
--- a/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/SynchronizedBenchmark.kt
+++ b/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/SynchronizedBenchmark.kt
@@ -16,8 +16,8 @@
package androidx.benchmark.benchmark
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
+import androidx.benchmark.junit4.BenchmarkRule
+import androidx.benchmark.junit4.measureRepeated
import androidx.test.filters.LargeTest
import org.junit.Rule
import org.junit.Test
diff --git a/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/TrivialJavaBenchmark.java b/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/TrivialJavaBenchmark.java
index bfad065..6146758 100644
--- a/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/TrivialJavaBenchmark.java
+++ b/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/TrivialJavaBenchmark.java
@@ -16,8 +16,8 @@
package androidx.benchmark.benchmark;
-import androidx.benchmark.BenchmarkRule;
import androidx.benchmark.BenchmarkState;
+import androidx.benchmark.junit4.BenchmarkRule;
import androidx.test.filters.LargeTest;
import org.junit.Rule;
diff --git a/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/TrivialKotlinBenchmark.kt b/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/TrivialKotlinBenchmark.kt
index c06742f..7260645 100644
--- a/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/TrivialKotlinBenchmark.kt
+++ b/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/TrivialKotlinBenchmark.kt
@@ -16,8 +16,8 @@
package androidx.benchmark.benchmark
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
+import androidx.benchmark.junit4.BenchmarkRule
+import androidx.benchmark.junit4.measureRepeated
import androidx.test.filters.LargeTest
import org.junit.Rule
import org.junit.Test
diff --git a/benchmark/common/api/1.0.0-alpha04.txt b/benchmark/common/api/1.0.0-alpha04.txt
index 96d4bc8..6849f29 100644
--- a/benchmark/common/api/1.0.0-alpha04.txt
+++ b/benchmark/common/api/1.0.0-alpha04.txt
@@ -1,29 +1,10 @@
// Signature format: 3.0
package androidx.benchmark {
- public class AndroidBenchmarkRunner extends androidx.test.runner.AndroidJUnitRunner {
- ctor public AndroidBenchmarkRunner();
- }
-
public final class ArgumentsKt {
ctor public ArgumentsKt();
}
- public final class BenchmarkRule implements org.junit.rules.TestRule {
- ctor public BenchmarkRule();
- method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description);
- method public androidx.benchmark.BenchmarkState getState();
- }
-
- public final class BenchmarkRule.Scope {
- method public inline <T> T! runWithTimingDisabled(kotlin.jvm.functions.Function0<? extends T> block);
- }
-
- public final class BenchmarkRuleKt {
- ctor public BenchmarkRuleKt();
- method public static inline void measureRepeated(androidx.benchmark.BenchmarkRule, kotlin.jvm.functions.Function1<? super androidx.benchmark.BenchmarkRule.Scope,kotlin.Unit> block);
- }
-
public final class BenchmarkState {
method public boolean keepRunning();
method public void pauseTiming();
diff --git a/benchmark/common/api/api_lint.ignore b/benchmark/common/api/api_lint.ignore
deleted file mode 100644
index 0a0591c..0000000
--- a/benchmark/common/api/api_lint.ignore
+++ /dev/null
@@ -1,7 +0,0 @@
-// Baseline format: 1.0
-DocumentExceptions: androidx.benchmark.BenchmarkRule#getState():
- Method BenchmarkRule.getState appears to be throwing java.lang.IllegalStateException; this should be listed in the documentation; see https://android.github.io/kotlin-guides/interop.html#document-exceptions
-DocumentExceptions: androidx.benchmark.BenchmarkState#pauseTiming():
- Method BenchmarkState.pauseTiming appears to be throwing java.lang.IllegalStateException; this should be listed in the documentation; see https://android.github.io/kotlin-guides/interop.html#document-exceptions
-DocumentExceptions: androidx.benchmark.BenchmarkState#resumeTiming():
- Method BenchmarkState.resumeTiming appears to be throwing java.lang.IllegalStateException; this should be listed in the documentation; see https://android.github.io/kotlin-guides/interop.html#document-exceptions
diff --git a/benchmark/common/api/current.txt b/benchmark/common/api/current.txt
index 96d4bc8..6849f29 100644
--- a/benchmark/common/api/current.txt
+++ b/benchmark/common/api/current.txt
@@ -1,29 +1,10 @@
// Signature format: 3.0
package androidx.benchmark {
- public class AndroidBenchmarkRunner extends androidx.test.runner.AndroidJUnitRunner {
- ctor public AndroidBenchmarkRunner();
- }
-
public final class ArgumentsKt {
ctor public ArgumentsKt();
}
- public final class BenchmarkRule implements org.junit.rules.TestRule {
- ctor public BenchmarkRule();
- method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description);
- method public androidx.benchmark.BenchmarkState getState();
- }
-
- public final class BenchmarkRule.Scope {
- method public inline <T> T! runWithTimingDisabled(kotlin.jvm.functions.Function0<? extends T> block);
- }
-
- public final class BenchmarkRuleKt {
- ctor public BenchmarkRuleKt();
- method public static inline void measureRepeated(androidx.benchmark.BenchmarkRule, kotlin.jvm.functions.Function1<? super androidx.benchmark.BenchmarkRule.Scope,kotlin.Unit> block);
- }
-
public final class BenchmarkState {
method public boolean keepRunning();
method public void pauseTiming();
diff --git a/benchmark/common/api/restricted_1.0.0-alpha04.txt b/benchmark/common/api/restricted_1.0.0-alpha04.txt
index 35c0a19..4165e3e 100644
--- a/benchmark/common/api/restricted_1.0.0-alpha04.txt
+++ b/benchmark/common/api/restricted_1.0.0-alpha04.txt
@@ -1,40 +1,31 @@
// Signature format: 3.0
package androidx.benchmark {
- public class AndroidBenchmarkRunner extends androidx.test.runner.AndroidJUnitRunner {
- ctor public AndroidBenchmarkRunner();
- }
-
public final class ArgumentsKt {
ctor public ArgumentsKt();
}
- public final class BenchmarkRule implements org.junit.rules.TestRule {
- ctor public BenchmarkRule();
- method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description);
- method public androidx.benchmark.BenchmarkState getState();
- }
-
- public final class BenchmarkRule.Scope {
- method public inline <T> T! runWithTimingDisabled(kotlin.jvm.functions.Function0<? extends T> block);
- }
-
- public final class BenchmarkRuleKt {
- ctor public BenchmarkRuleKt();
- method public static inline void measureRepeated(androidx.benchmark.BenchmarkRule, kotlin.jvm.functions.Function1<? super androidx.benchmark.BenchmarkRule.Scope,kotlin.Unit> block);
- }
-
public final class BenchmarkState {
+ ctor @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public BenchmarkState();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public long getMin();
method public boolean keepRunning();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public inline boolean keepRunningInline();
method public void pauseTiming();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public void report(String fullClassName, String simpleClassName, String methodName);
method public static void reportData(String className, String testName, long totalRunTimeNs, java.util.List<java.lang.Long> dataNs, @IntRange(from=0) int warmupIterations, @IntRange(from=0) long thermalThrottleSleepSeconds, @IntRange(from=1) int repeatIterations);
method public void resumeTiming();
}
+ @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public final class IsolationActivity extends android.app.Activity {
+ method public void actuallyFinish();
+ field public static final androidx.benchmark.IsolationActivity.Companion! Companion;
+ }
public static final class IsolationActivity.Companion {
method @AnyThread public void finishSingleton();
+ method public boolean getResumed();
method @WorkerThread public void launchSingleton();
+ property public final boolean resumed;
}
}
diff --git a/benchmark/common/api/restricted_current.txt b/benchmark/common/api/restricted_current.txt
index 35c0a19..4165e3e 100644
--- a/benchmark/common/api/restricted_current.txt
+++ b/benchmark/common/api/restricted_current.txt
@@ -1,40 +1,31 @@
// Signature format: 3.0
package androidx.benchmark {
- public class AndroidBenchmarkRunner extends androidx.test.runner.AndroidJUnitRunner {
- ctor public AndroidBenchmarkRunner();
- }
-
public final class ArgumentsKt {
ctor public ArgumentsKt();
}
- public final class BenchmarkRule implements org.junit.rules.TestRule {
- ctor public BenchmarkRule();
- method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description);
- method public androidx.benchmark.BenchmarkState getState();
- }
-
- public final class BenchmarkRule.Scope {
- method public inline <T> T! runWithTimingDisabled(kotlin.jvm.functions.Function0<? extends T> block);
- }
-
- public final class BenchmarkRuleKt {
- ctor public BenchmarkRuleKt();
- method public static inline void measureRepeated(androidx.benchmark.BenchmarkRule, kotlin.jvm.functions.Function1<? super androidx.benchmark.BenchmarkRule.Scope,kotlin.Unit> block);
- }
-
public final class BenchmarkState {
+ ctor @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public BenchmarkState();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public long getMin();
method public boolean keepRunning();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public inline boolean keepRunningInline();
method public void pauseTiming();
+ method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public void report(String fullClassName, String simpleClassName, String methodName);
method public static void reportData(String className, String testName, long totalRunTimeNs, java.util.List<java.lang.Long> dataNs, @IntRange(from=0) int warmupIterations, @IntRange(from=0) long thermalThrottleSleepSeconds, @IntRange(from=1) int repeatIterations);
method public void resumeTiming();
}
+ @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public final class IsolationActivity extends android.app.Activity {
+ method public void actuallyFinish();
+ field public static final androidx.benchmark.IsolationActivity.Companion! Companion;
+ }
public static final class IsolationActivity.Companion {
method @AnyThread public void finishSingleton();
+ method public boolean getResumed();
method @WorkerThread public void launchSingleton();
+ property public final boolean resumed;
}
}
diff --git a/benchmark/common/build.gradle b/benchmark/common/build.gradle
index b4b2f26..488d327 100644
--- a/benchmark/common/build.gradle
+++ b/benchmark/common/build.gradle
@@ -25,27 +25,20 @@
id("kotlin-android")
}
-android {
- defaultConfig {
- testInstrumentationRunner "androidx.benchmark.AndroidBenchmarkRunner"
- }
-}
-
dependencies {
- implementation(ANDROIDX_TEST_RULES)
- implementation(ANDROIDX_TEST_RUNNER)
implementation(KOTLIN_STDLIB)
implementation(SUPPORT_ANNOTATIONS)
+ implementation(ANDROIDX_TEST_MONITOR)
- androidTestImplementation(ANDROIDX_TEST_CORE)
+ androidTestImplementation(ANDROIDX_TEST_RULES)
androidTestImplementation(ANDROIDX_TEST_EXT_JUNIT)
}
androidx {
- name = "Android Benchmark"
+ name = "Android Benchmark Common"
publish = Publish.SNAPSHOT_AND_RELEASE
mavenVersion = LibraryVersions.BENCHMARK
mavenGroup = LibraryGroups.BENCHMARK
inceptionYear = "2018"
- description = "Android Benchmark"
+ description = "Android Benchmark Common"
}
diff --git a/benchmark/common/src/androidTest/AndroidManifest.xml b/benchmark/common/src/androidTest/AndroidManifest.xml
index f5ec776..bcc3cf4 100644
--- a/benchmark/common/src/androidTest/AndroidManifest.xml
+++ b/benchmark/common/src/androidTest/AndroidManifest.xml
@@ -16,11 +16,8 @@
-->
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
package="androidx.benchmark.test">
<application
- android:name="androidx.benchmark.ArgumentInjectingApplication">
- <activity android:name="android.app.Activity"/>
- </application>
+ android:name="androidx.benchmark.ArgumentInjectingApplication"/>
</manifest>
\ No newline at end of file
diff --git a/benchmark/common/src/androidTest/java/androidx/benchmark/ArgumentInjectingApplication.kt b/benchmark/common/src/androidTest/java/androidx/benchmark/ArgumentInjectingApplication.kt
index 30b3bd3..31f45ce 100644
--- a/benchmark/common/src/androidTest/java/androidx/benchmark/ArgumentInjectingApplication.kt
+++ b/benchmark/common/src/androidTest/java/androidx/benchmark/ArgumentInjectingApplication.kt
@@ -43,9 +43,12 @@
// Since these benchmark correctness tests run as part of the regular
// (non-performance-test) suite, they will have debuggable=true, won't be clock-locked,
// can run with low-battery or on an emulator, and code coverage enabled.
+ // We also don't have the activity up for these correctness tests, instead
+ // leaving testing that behavior to the junit4 module.
putString(
"androidx.benchmark.suppressErrors",
- "CODE-COVERAGE,DEBUGGABLE,EMULATOR,LOW-BATTERY,UNLOCKED"
+ "ACTIVITY-MISSING,CODE-COVERAGE,DEBUGGABLE,EMULATOR,LOW-BATTERY,UNLOCKED," +
+ "UNSUSTAINED-ACTIVITY-MISSING"
)
}
}
diff --git a/benchmark/common/src/androidTest/java/androidx/benchmark/BenchmarkStateTest.kt b/benchmark/common/src/androidTest/java/androidx/benchmark/BenchmarkStateTest.kt
index 2c49b0a..e8ac0ab 100644
--- a/benchmark/common/src/androidTest/java/androidx/benchmark/BenchmarkStateTest.kt
+++ b/benchmark/common/src/androidTest/java/androidx/benchmark/BenchmarkStateTest.kt
@@ -99,7 +99,7 @@
)
// check attribute presence and naming
- val prefix = Errors.WARNING_PREFIX
+ val prefix = Errors.PREFIX
assertNotNull(bundle.get("${prefix}min"))
assertNotNull(bundle.get("${prefix}mean"))
assertNotNull(bundle.get("${prefix}count"))
diff --git a/benchmark/common/src/main/java/androidx/benchmark/BenchmarkState.kt b/benchmark/common/src/main/java/androidx/benchmark/BenchmarkState.kt
index f0adc87..7d55169 100644
--- a/benchmark/common/src/main/java/androidx/benchmark/BenchmarkState.kt
+++ b/benchmark/common/src/main/java/androidx/benchmark/BenchmarkState.kt
@@ -22,9 +22,10 @@
import android.os.Debug
import android.util.Log
import androidx.annotation.IntRange
+import androidx.annotation.RestrictTo
import androidx.annotation.VisibleForTesting
+import androidx.benchmark.Errors.PREFIX
import androidx.test.platform.app.InstrumentationRegistry
-import org.junit.Assert.fail
import java.io.File
import java.text.NumberFormat
import java.util.ArrayList
@@ -53,7 +54,12 @@
*
* @see BenchmarkRule#getState()
*/
-class BenchmarkState internal constructor() {
+class BenchmarkState {
+ /** @hide */
+ @Suppress("ConvertSecondaryConstructorToPrimary")
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ constructor() {}
+
private var warmupIteration = 0 // increasing iteration count during warmup
/**
@@ -122,6 +128,14 @@
}
/**
+ * Used for testing in other modules
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ fun getMin(): Long = stats.min
+
+ /**
* Stops the benchmark timer.
*
* This method can be called only when the timer is running.
@@ -141,6 +155,8 @@
* }
* ```
*
+ * @throws [IllegalStateException] if the benchmark is already paused.
+ *
* @see resumeTiming
*/
fun pauseTiming() {
@@ -171,6 +187,9 @@
* processBitmap(input);
* }
* }
+ *
+ * @throws [IllegalStateException] if the benchmark is already running.
+ *
* ```
*
* @see pauseTiming
@@ -258,10 +277,12 @@
* This codepath uses exclusively @JvmField/const members, so there are no method calls at all
* in the inlined loop. On recent Android Platform versions, ART inlines these accessors anyway,
* but we want to be sure it's as simple as possible.
+ *
+ * @hide
*/
@Suppress("NOTHING_TO_INLINE")
- @PublishedApi
- internal inline fun keepRunningInline(): Boolean {
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ inline fun keepRunningInline(): Boolean {
if (iterationsRemaining > 1) {
iterationsRemaining--
return true
@@ -292,11 +313,12 @@
when (state) {
NOT_STARTED -> {
if (Errors.UNSUPPRESSED_WARNING_MESSAGE != null) {
- fail(Errors.UNSUPPRESSED_WARNING_MESSAGE)
+ throw AssertionError(Errors.UNSUPPRESSED_WARNING_MESSAGE)
}
if (!firstBenchmark && Arguments.startupMode) {
- fail("Error - multiple benchmarks in startup mode. Only one benchmark " +
- "may be run per 'am instrument' call, to ensure result isolation.")
+ throw AssertionError("Error - multiple benchmarks in startup mode. Only one " +
+ "benchmark may be run per 'am instrument' call, to ensure result " +
+ "isolation.")
}
firstBenchmark = false
@@ -392,17 +414,16 @@
Log.i(TAG, key + summaryLine())
val status = Bundle()
- val prefix = Errors.WARNING_PREFIX
- status.putLong("${prefix}median", stats.median)
- status.putLong("${prefix}mean", stats.mean.toLong())
- status.putLong("${prefix}min", stats.min)
- status.putLong("${prefix}standardDeviation", stats.standardDeviation.toLong())
- status.putLong("${prefix}count", maxIterations.toLong())
+ status.putLong("${PREFIX}median", stats.median)
+ status.putLong("${PREFIX}mean", stats.mean.toLong())
+ status.putLong("${PREFIX}min", stats.min)
+ status.putLong("${PREFIX}standardDeviation", stats.standardDeviation.toLong())
+ status.putLong("${PREFIX}count", maxIterations.toLong())
status.putIdeSummaryLine(key, stats.min)
return status
}
- internal fun sendStatus(testName: String) {
+ private fun sendStatus(testName: String) {
val bundle = getFullStatusReport(testName)
InstrumentationRegistry.getInstrumentation().sendStatus(Activity.RESULT_OK, bundle)
}
@@ -419,6 +440,26 @@
else -> false
}
+ /**
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ fun report(
+ fullClassName: String,
+ simpleClassName: String,
+ methodName: String
+ ) {
+ val fullTestName = "$PREFIX$simpleClassName.$methodName"
+ sendStatus(fullTestName)
+
+ ResultWriter.appendReport(
+ getReport(
+ testName = PREFIX + methodName,
+ className = fullClassName
+ )
+ )
+ }
+
internal companion object {
private const val TAG = "Benchmark"
private const val STUDIO_OUTPUT_KEY_PREFIX = "android.studio.display."
@@ -482,7 +523,7 @@
// Report value to Studio console
val bundle = Bundle()
- val fullTestName = Errors.WARNING_PREFIX +
+ val fullTestName = Errors.PREFIX +
if (className.isNotEmpty()) "$className.$testName" else testName
bundle.putIdeSummaryLine(fullTestName, report.stats.min)
InstrumentationRegistry.getInstrumentation().sendStatus(Activity.RESULT_OK, bundle)
diff --git a/benchmark/common/src/main/java/androidx/benchmark/Errors.kt b/benchmark/common/src/main/java/androidx/benchmark/Errors.kt
index 6c5eabf..ce47af7 100644
--- a/benchmark/common/src/main/java/androidx/benchmark/Errors.kt
+++ b/benchmark/common/src/main/java/androidx/benchmark/Errors.kt
@@ -26,7 +26,7 @@
import java.io.File
/**
- * Lazy-initialized test-suite global state for warnings around measurement inaccuracy.
+ * Lazy-initialized test-suite global state for errors around measurement inaccuracy.
*/
internal object Errors {
/**
@@ -44,7 +44,7 @@
private const val TAG = "Benchmark"
- val WARNING_PREFIX: String
+ val PREFIX: String
val UNSUPPRESSED_WARNING_MESSAGE: String?
private var warningString: String? = null
@@ -190,13 +190,13 @@
""".trimMarginWrapNewlines()
}
- WARNING_PREFIX = warningPrefix
+ PREFIX = warningPrefix
if (warningString.isNotEmpty()) {
this.warningString = warningString
warningString.split("\n").map { Log.w(TAG, it) }
}
- val warningSet = WARNING_PREFIX
+ val warningSet = PREFIX
.split('_')
.filter { it.isNotEmpty() }
.toSet()
diff --git a/benchmark/common/src/main/java/androidx/benchmark/IsolationActivity.kt b/benchmark/common/src/main/java/androidx/benchmark/IsolationActivity.kt
index 2e736a4..18fe7c7 100644
--- a/benchmark/common/src/main/java/androidx/benchmark/IsolationActivity.kt
+++ b/benchmark/common/src/main/java/androidx/benchmark/IsolationActivity.kt
@@ -46,7 +46,7 @@
*
* @hide
*/
-@RestrictTo(RestrictTo.Scope.LIBRARY)
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
class IsolationActivity : android.app.Activity() {
private var destroyed = false
@@ -123,7 +123,7 @@
private var firstInit = true
internal var sustainedPerformanceModeInUse = false
private set
- internal var resumed = false
+ var resumed = false
private set
@WorkerThread
diff --git a/benchmark/integration-tests/startup-benchmark/build.gradle b/benchmark/integration-tests/startup-benchmark/build.gradle
index 7b71828..4219241 100644
--- a/benchmark/integration-tests/startup-benchmark/build.gradle
+++ b/benchmark/integration-tests/startup-benchmark/build.gradle
@@ -23,7 +23,7 @@
}
dependencies {
- androidTestImplementation(project(":benchmark:benchmark-common"))
+ androidTestImplementation(project(":benchmark:benchmark-junit4"))
androidTestImplementation(ANDROIDX_TEST_RUNNER)
androidTestImplementation(JUNIT)
androidTestImplementation(KOTLIN_STDLIB)
diff --git a/benchmark/integration-tests/startup-benchmark/src/androidTest/java/androidx/benchmark/integration/startup/benchmark/StartupBenchmark.kt b/benchmark/integration-tests/startup-benchmark/src/androidTest/java/androidx/benchmark/integration/startup/benchmark/StartupBenchmark.kt
index aa4f280..d4f9464 100644
--- a/benchmark/integration-tests/startup-benchmark/src/androidTest/java/androidx/benchmark/integration/startup/benchmark/StartupBenchmark.kt
+++ b/benchmark/integration-tests/startup-benchmark/src/androidTest/java/androidx/benchmark/integration/startup/benchmark/StartupBenchmark.kt
@@ -16,8 +16,8 @@
package androidx.benchmark.integration.startup.benchmark
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
+import androidx.benchmark.junit4.BenchmarkRule
+import androidx.benchmark.junit4.measureRepeated
import androidx.test.filters.LargeTest
import org.junit.Assert.assertEquals
import org.junit.Rule
diff --git a/benchmark/junit4/api/1.0.0-alpha04.txt b/benchmark/junit4/api/1.0.0-alpha04.txt
new file mode 100644
index 0000000..756b010
--- /dev/null
+++ b/benchmark/junit4/api/1.0.0-alpha04.txt
@@ -0,0 +1,24 @@
+// Signature format: 3.0
+package androidx.benchmark.junit4 {
+
+ public class AndroidBenchmarkRunner extends androidx.test.runner.AndroidJUnitRunner {
+ ctor public AndroidBenchmarkRunner();
+ }
+
+ public final class BenchmarkRule implements org.junit.rules.TestRule {
+ ctor public BenchmarkRule();
+ method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description);
+ method public androidx.benchmark.BenchmarkState getState();
+ }
+
+ public final class BenchmarkRule.Scope {
+ method public inline <T> T! runWithTimingDisabled(kotlin.jvm.functions.Function0<? extends T> block);
+ }
+
+ public final class BenchmarkRuleKt {
+ ctor public BenchmarkRuleKt();
+ method public static inline void measureRepeated(androidx.benchmark.junit4.BenchmarkRule, kotlin.jvm.functions.Function1<? super androidx.benchmark.junit4.BenchmarkRule.Scope,kotlin.Unit> block);
+ }
+
+}
+
diff --git a/benchmark/junit4/api/current.txt b/benchmark/junit4/api/current.txt
new file mode 100644
index 0000000..756b010
--- /dev/null
+++ b/benchmark/junit4/api/current.txt
@@ -0,0 +1,24 @@
+// Signature format: 3.0
+package androidx.benchmark.junit4 {
+
+ public class AndroidBenchmarkRunner extends androidx.test.runner.AndroidJUnitRunner {
+ ctor public AndroidBenchmarkRunner();
+ }
+
+ public final class BenchmarkRule implements org.junit.rules.TestRule {
+ ctor public BenchmarkRule();
+ method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description);
+ method public androidx.benchmark.BenchmarkState getState();
+ }
+
+ public final class BenchmarkRule.Scope {
+ method public inline <T> T! runWithTimingDisabled(kotlin.jvm.functions.Function0<? extends T> block);
+ }
+
+ public final class BenchmarkRuleKt {
+ ctor public BenchmarkRuleKt();
+ method public static inline void measureRepeated(androidx.benchmark.junit4.BenchmarkRule, kotlin.jvm.functions.Function1<? super androidx.benchmark.junit4.BenchmarkRule.Scope,kotlin.Unit> block);
+ }
+
+}
+
diff --git a/benchmark/junit4/api/res-1.0.0-alpha04.txt b/benchmark/junit4/api/res-1.0.0-alpha04.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/benchmark/junit4/api/res-1.0.0-alpha04.txt
diff --git a/benchmark/junit4/api/restricted_1.0.0-alpha04.txt b/benchmark/junit4/api/restricted_1.0.0-alpha04.txt
new file mode 100644
index 0000000..756b010
--- /dev/null
+++ b/benchmark/junit4/api/restricted_1.0.0-alpha04.txt
@@ -0,0 +1,24 @@
+// Signature format: 3.0
+package androidx.benchmark.junit4 {
+
+ public class AndroidBenchmarkRunner extends androidx.test.runner.AndroidJUnitRunner {
+ ctor public AndroidBenchmarkRunner();
+ }
+
+ public final class BenchmarkRule implements org.junit.rules.TestRule {
+ ctor public BenchmarkRule();
+ method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description);
+ method public androidx.benchmark.BenchmarkState getState();
+ }
+
+ public final class BenchmarkRule.Scope {
+ method public inline <T> T! runWithTimingDisabled(kotlin.jvm.functions.Function0<? extends T> block);
+ }
+
+ public final class BenchmarkRuleKt {
+ ctor public BenchmarkRuleKt();
+ method public static inline void measureRepeated(androidx.benchmark.junit4.BenchmarkRule, kotlin.jvm.functions.Function1<? super androidx.benchmark.junit4.BenchmarkRule.Scope,kotlin.Unit> block);
+ }
+
+}
+
diff --git a/benchmark/junit4/api/restricted_current.txt b/benchmark/junit4/api/restricted_current.txt
new file mode 100644
index 0000000..756b010
--- /dev/null
+++ b/benchmark/junit4/api/restricted_current.txt
@@ -0,0 +1,24 @@
+// Signature format: 3.0
+package androidx.benchmark.junit4 {
+
+ public class AndroidBenchmarkRunner extends androidx.test.runner.AndroidJUnitRunner {
+ ctor public AndroidBenchmarkRunner();
+ }
+
+ public final class BenchmarkRule implements org.junit.rules.TestRule {
+ ctor public BenchmarkRule();
+ method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description);
+ method public androidx.benchmark.BenchmarkState getState();
+ }
+
+ public final class BenchmarkRule.Scope {
+ method public inline <T> T! runWithTimingDisabled(kotlin.jvm.functions.Function0<? extends T> block);
+ }
+
+ public final class BenchmarkRuleKt {
+ ctor public BenchmarkRuleKt();
+ method public static inline void measureRepeated(androidx.benchmark.junit4.BenchmarkRule, kotlin.jvm.functions.Function1<? super androidx.benchmark.junit4.BenchmarkRule.Scope,kotlin.Unit> block);
+ }
+
+}
+
diff --git a/benchmark/junit4/build.gradle b/benchmark/junit4/build.gradle
new file mode 100644
index 0000000..6fa16a5
--- /dev/null
+++ b/benchmark/junit4/build.gradle
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import static androidx.build.dependencies.DependenciesKt.*
+import androidx.build.LibraryGroups
+import androidx.build.LibraryVersions
+import androidx.build.Publish
+
+plugins {
+ id("AndroidXPlugin")
+ id("com.android.library")
+ id("kotlin-android")
+}
+
+android {
+ defaultConfig {
+ testInstrumentationRunner "androidx.benchmark.junit4.AndroidBenchmarkRunner"
+ }
+}
+
+dependencies {
+ api(project(":benchmark:benchmark-common"))
+
+ api(JUNIT)
+ api(KOTLIN_STDLIB)
+
+ implementation(ANDROIDX_TEST_RULES)
+ implementation(ANDROIDX_TEST_RUNNER)
+ implementation(SUPPORT_ANNOTATIONS)
+
+ androidTestImplementation(ANDROIDX_TEST_EXT_JUNIT)
+}
+
+androidx {
+ name = "Android Benchmark - JUnit4"
+ publish = Publish.SNAPSHOT_AND_RELEASE
+ mavenVersion = LibraryVersions.BENCHMARK
+ mavenGroup = LibraryGroups.BENCHMARK
+ inceptionYear = "2019"
+ description = "Android Benchmark - JUnit4"
+}
diff --git a/benchmark/junit4/src/androidTest/AndroidManifest.xml b/benchmark/junit4/src/androidTest/AndroidManifest.xml
new file mode 100644
index 0000000..7398a5f
--- /dev/null
+++ b/benchmark/junit4/src/androidTest/AndroidManifest.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<manifest
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ package="androidx.benchmark.junit4.test">
+
+ <application
+ android:name="androidx.benchmark.junit4.ArgumentInjectingApplication">
+ <activity android:name="android.app.Activity"/>
+ </application>
+</manifest>
\ No newline at end of file
diff --git a/benchmark/common/src/androidTest/java/androidx/benchmark/ActivityBenchmarkTests.kt b/benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/ActivityBenchmarkTests.kt
similarity index 93%
rename from benchmark/common/src/androidTest/java/androidx/benchmark/ActivityBenchmarkTests.kt
rename to benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/ActivityBenchmarkTests.kt
index 19e8c76..d8db6e7 100644
--- a/benchmark/common/src/androidTest/java/androidx/benchmark/ActivityBenchmarkTests.kt
+++ b/benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/ActivityBenchmarkTests.kt
@@ -14,15 +14,16 @@
* limitations under the License.
*/
-package androidx.benchmark
+package androidx.benchmark.junit4
import android.app.Activity
+import androidx.benchmark.IsolationActivity
import androidx.test.annotation.UiThreadTest
import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.filters.LargeTest
import androidx.test.rule.ActivityTestRule
-import org.junit.Assert
+import org.junit.Assert.assertFalse
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -31,7 +32,7 @@
fun BenchmarkRule.validateRunWithIsolationActivityHidden() {
// isolation activity *not* on top
- Assert.assertFalse(IsolationActivity.resumed)
+ assertFalse(IsolationActivity.resumed)
measureRepeated {}
}
diff --git a/benchmark/common/src/androidTest/java/androidx/benchmark/AndroidBenchmarkRunnerTest.kt b/benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/AndroidBenchmarkRunnerTest.kt
similarity index 92%
rename from benchmark/common/src/androidTest/java/androidx/benchmark/AndroidBenchmarkRunnerTest.kt
rename to benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/AndroidBenchmarkRunnerTest.kt
index 1ae2ab5..d5b70f9 100644
--- a/benchmark/common/src/androidTest/java/androidx/benchmark/AndroidBenchmarkRunnerTest.kt
+++ b/benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/AndroidBenchmarkRunnerTest.kt
@@ -14,8 +14,9 @@
* limitations under the License.
*/
-package androidx.benchmark
+package androidx.benchmark.junit4
+import androidx.benchmark.IsolationActivity
import androidx.test.annotation.UiThreadTest
import androidx.test.filters.SmallTest
import org.junit.Assert.assertTrue
diff --git a/benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/ArgumentInjectingApplication.kt b/benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/ArgumentInjectingApplication.kt
new file mode 100644
index 0000000..233fc11
--- /dev/null
+++ b/benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/ArgumentInjectingApplication.kt
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.benchmark.junit4
+
+import android.app.Application
+import android.os.Bundle
+import androidx.benchmark.argumentSource
+
+/**
+ * Hack to enable overriding benchmark arguments (since we can't easily do this in CI, per apk)
+ *
+ * The *correct* way to do this would be to put the following in benchmark/build.gradle:
+ *
+ * ```
+ * android {
+ * defaultConfig {
+ * testInstrumentationRunnerArgument 'androidx.benchmark.suppressErrors',
+ * 'CODE-COVERAGE,DEBUGGABLE,EMULATOR,LOW-BATTERY,UNLOCKED'
+ * }
+ * }
+ * ```
+ */
+class ArgumentInjectingApplication : Application() {
+ override fun onCreate() {
+ super.onCreate()
+
+ argumentSource = Bundle().apply {
+ putString("androidx.benchmark.output.enable", "true")
+
+ // Since these benchmark correctness tests run as part of the regular
+ // (non-performance-test) suite, they will have debuggable=true, won't be clock-locked,
+ // can run with low-battery or on an emulator, and code coverage enabled.
+ putString(
+ "androidx.benchmark.suppressErrors",
+ "CODE-COVERAGE,DEBUGGABLE,EMULATOR,LOW-BATTERY,UNLOCKED"
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/benchmark/common/src/androidTest/java/androidx/benchmark/BenchmarkRuleAnnotationTest.kt b/benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/BenchmarkRuleAnnotationTest.kt
similarity index 96%
rename from benchmark/common/src/androidTest/java/androidx/benchmark/BenchmarkRuleAnnotationTest.kt
rename to benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/BenchmarkRuleAnnotationTest.kt
index c6c8ddc..6a0c62c 100644
--- a/benchmark/common/src/androidTest/java/androidx/benchmark/BenchmarkRuleAnnotationTest.kt
+++ b/benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/BenchmarkRuleAnnotationTest.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package androidx.benchmark
+package androidx.benchmark.junit4
import androidx.test.filters.SmallTest
import org.junit.Test
diff --git a/benchmark/common/src/androidTest/java/androidx/benchmark/BenchmarkRuleTest.kt b/benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/BenchmarkRuleTest.kt
similarity index 93%
rename from benchmark/common/src/androidTest/java/androidx/benchmark/BenchmarkRuleTest.kt
rename to benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/BenchmarkRuleTest.kt
index 8e988f0..87e5697 100644
--- a/benchmark/common/src/androidTest/java/androidx/benchmark/BenchmarkRuleTest.kt
+++ b/benchmark/junit4/src/androidTest/java/androidx/benchmark/junit4/BenchmarkRuleTest.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package androidx.benchmark
+package androidx.benchmark.junit4
import androidx.test.filters.LargeTest
import org.junit.Assert.assertTrue
@@ -37,7 +37,7 @@
Thread.sleep(5)
}
}
- val min = benchmarkRule.getState().stats.min
+ val min = benchmarkRule.getState().getMin()
assertTrue("minimum $min should be less than 1ms",
min < TimeUnit.MILLISECONDS.toNanos(1))
}
diff --git a/benchmark/junit4/src/main/AndroidManifest.xml b/benchmark/junit4/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..ee4f8b9
--- /dev/null
+++ b/benchmark/junit4/src/main/AndroidManifest.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<manifest package="androidx.benchmark.junit4"/>
diff --git a/benchmark/common/src/main/java/androidx/benchmark/AndroidBenchmarkRunner.kt b/benchmark/junit4/src/main/java/androidx/benchmark/junit4/AndroidBenchmarkRunner.kt
similarity index 97%
rename from benchmark/common/src/main/java/androidx/benchmark/AndroidBenchmarkRunner.kt
rename to benchmark/junit4/src/main/java/androidx/benchmark/junit4/AndroidBenchmarkRunner.kt
index 68a0cef..1ca90b3 100644
--- a/benchmark/common/src/main/java/androidx/benchmark/AndroidBenchmarkRunner.kt
+++ b/benchmark/junit4/src/main/java/androidx/benchmark/junit4/AndroidBenchmarkRunner.kt
@@ -14,9 +14,10 @@
* limitations under the License.
*/
-package androidx.benchmark
+package androidx.benchmark.junit4
import androidx.annotation.CallSuper
+import androidx.benchmark.IsolationActivity
import androidx.test.runner.AndroidJUnitRunner
/**
diff --git a/benchmark/common/src/main/java/androidx/benchmark/BenchmarkRule.kt b/benchmark/junit4/src/main/java/androidx/benchmark/junit4/BenchmarkRule.kt
similarity index 82%
rename from benchmark/common/src/main/java/androidx/benchmark/BenchmarkRule.kt
rename to benchmark/junit4/src/main/java/androidx/benchmark/junit4/BenchmarkRule.kt
index 97b114f..496d536 100644
--- a/benchmark/common/src/main/java/androidx/benchmark/BenchmarkRule.kt
+++ b/benchmark/junit4/src/main/java/androidx/benchmark/junit4/BenchmarkRule.kt
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package androidx.benchmark
+package androidx.benchmark.junit4
import android.Manifest
import android.util.Log
import androidx.annotation.RestrictTo
-import androidx.benchmark.Errors.WARNING_PREFIX
+import androidx.benchmark.BenchmarkState
import androidx.test.rule.GrantPermissionRule
import org.junit.Assert.assertTrue
import org.junit.rules.RuleChain
@@ -106,6 +106,8 @@
* ...
* }
* ```
+ *
+ * @throws [IllegalStateException] if the BenchmarkRule isn't correctly applied to a test.
*/
fun getState(): BenchmarkState {
// Note: this is an explicit method instead of an accessor to help convey it's only for Java
@@ -169,38 +171,37 @@
.apply(base, description)
}
- private fun applyInternal(base: Statement, description: Description) = Statement {
- applied = true
- var invokeMethodName = description.methodName
- Log.i(TAG, "Running ${description.className}#$invokeMethodName")
-
- // validate and simplify the function name.
- // First, remove the "test" prefix which normally comes from CTS test.
- // Then make sure the [subTestName] is valid, not just numbers like [0].
- if (invokeMethodName.startsWith("test")) {
- assertTrue(
- "The test name $invokeMethodName is too short",
- invokeMethodName.length > 5
+ private fun applyInternal(base: Statement, description: Description) =
+ Statement {
+ applied = true
+ var invokeMethodName = description.methodName
+ Log.i(
+ TAG,
+ "Running ${description.className}#$invokeMethodName"
)
- invokeMethodName = invokeMethodName.substring(4, 5).toLowerCase() +
- invokeMethodName.substring(5)
- }
- base.evaluate()
-
- if (enableReport) {
- val fullTestName =
- WARNING_PREFIX + description.testClass.simpleName + "." + invokeMethodName
- internalState.sendStatus(fullTestName)
-
- ResultWriter.appendReport(
- internalState.getReport(
- testName = WARNING_PREFIX + invokeMethodName,
- className = description.className
+ // validate and simplify the function name.
+ // First, remove the "test" prefix which normally comes from CTS test.
+ // Then make sure the [subTestName] is valid, not just numbers like [0].
+ if (invokeMethodName.startsWith("test")) {
+ assertTrue(
+ "The test name $invokeMethodName is too short",
+ invokeMethodName.length > 5
)
- )
+ invokeMethodName = invokeMethodName.substring(4, 5).toLowerCase() +
+ invokeMethodName.substring(5)
+ }
+
+ base.evaluate()
+
+ if (enableReport) {
+ internalState.report(
+ fullClassName = description.className,
+ simpleClassName = description.testClass.simpleName,
+ methodName = invokeMethodName
+ )
+ }
}
- }
internal companion object {
private const val TAG = "BenchmarkRule"
diff --git a/buildSrc/src/main/kotlin/androidx/build/SupportConfig.kt b/buildSrc/src/main/kotlin/androidx/build/SupportConfig.kt
index 34bd1bd..f9b32b8d 100644
--- a/buildSrc/src/main/kotlin/androidx/build/SupportConfig.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/SupportConfig.kt
@@ -23,7 +23,7 @@
object SupportConfig {
const val DEFAULT_MIN_SDK_VERSION = 14
const val INSTRUMENTATION_RUNNER = "androidx.test.runner.AndroidJUnitRunner"
- const val BENCHMARK_INSTRUMENTATION_RUNNER = "androidx.benchmark.AndroidBenchmarkRunner"
+ const val BENCHMARK_INSTRUMENTATION_RUNNER = "androidx.benchmark.junit4.AndroidBenchmarkRunner"
const val BUILD_TOOLS_VERSION = "28.0.3"
/**
diff --git a/buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt b/buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt
index 81ee4b7..7c83e43 100644
--- a/buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt
@@ -19,6 +19,7 @@
const val ANDROIDX_TEST_CORE = "androidx.test:core:1.1.0"
const val ANDROIDX_TEST_EXT_JUNIT = "androidx.test.ext:junit:1.1.0"
const val ANDROIDX_TEST_EXT_KTX = "androidx.test.ext:junit-ktx:1.1.0"
+const val ANDROIDX_TEST_MONITOR = "androidx.test:monitor:1.1.1"
const val ANDROIDX_TEST_RULES = "androidx.test:rules:1.1.0"
const val ANDROIDX_TEST_RUNNER = "androidx.test:runner:1.1.1"
const val ANDROIDX_TEST_UIAUTOMATOR = "androidx.test.uiautomator:uiautomator:2.2.0"
diff --git a/compose/compose-runtime/compose-runtime-benchmark/build.gradle b/compose/compose-runtime/compose-runtime-benchmark/build.gradle
index 93647df..07a7246 100644
--- a/compose/compose-runtime/compose-runtime-benchmark/build.gradle
+++ b/compose/compose-runtime/compose-runtime-benchmark/build.gradle
@@ -62,7 +62,7 @@
androidTestImplementation(ANDROIDX_TEST_RULES)
androidTestImplementation(KOTLIN_COMPOSE_STDLIB)
androidTestImplementation(KOTLIN_COMPOSE_REFLECT)
- androidTestImplementation(project(":benchmark:benchmark-common"))
+ androidTestImplementation(project(":benchmark:benchmark-junit4"))
}
tasks.withType(KotlinCompile).configureEach {
diff --git a/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/ComposeBenchmarkBase.kt b/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/ComposeBenchmarkBase.kt
index 880f183..8d72e02 100644
--- a/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/ComposeBenchmarkBase.kt
+++ b/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/ComposeBenchmarkBase.kt
@@ -16,8 +16,8 @@
package androidx.compose.benchmark
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
+import androidx.benchmark.junit4.BenchmarkRule
+import androidx.benchmark.junit4.measureRepeated
import androidx.compose.Composable
import androidx.compose.Composer
import androidx.compose.FrameManager
diff --git a/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/DbMonsterBenchmark.kt b/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/DbMonsterBenchmark.kt
index 3d4551d..6e38b77 100644
--- a/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/DbMonsterBenchmark.kt
+++ b/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/DbMonsterBenchmark.kt
@@ -17,8 +17,6 @@
package androidx.compose.benchmark
import android.app.Activity
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
import androidx.compose.Composable
import androidx.compose.Composer
import androidx.compose.FrameManager
@@ -50,7 +48,7 @@
@LargeTest
@RunWith(AndroidJUnit4::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-class DbMonsterBenchmark: ComposeBenchmarkBase() {
+class DbMonsterBenchmark : ComposeBenchmarkBase() {
@UiThreadTest
@Test
@@ -74,7 +72,7 @@
compose {
Table {
for (db in list.databases) {
- DatabaseRow(db=db)
+ DatabaseRow(db = db)
}
}
}
diff --git a/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/DeepTreeBenchmark.kt b/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/DeepTreeBenchmark.kt
index 1831c1f..89f4dd1 100644
--- a/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/DeepTreeBenchmark.kt
+++ b/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/DeepTreeBenchmark.kt
@@ -16,8 +16,6 @@
package androidx.compose.benchmark
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
import androidx.compose.Composable
import androidx.compose.benchmark.deeptree.DeepTree
import androidx.compose.disposeComposition
@@ -42,7 +40,7 @@
@LargeTest
@RunWith(AndroidJUnit4::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-class DeepTreeBenchmark: ComposeBenchmarkBase() {
+class DeepTreeBenchmark : ComposeBenchmarkBase() {
@UiThreadTest
@Test
fun benchmark_deep_tree_01_depth1_breadth100_wrap2() {
diff --git a/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/SiblingBenchmark.kt b/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/SiblingBenchmark.kt
index 2a05a9a..dd67ae1 100644
--- a/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/SiblingBenchmark.kt
+++ b/compose/compose-runtime/compose-runtime-benchmark/src/androidTest/java/androidx/compose/benchmark/SiblingBenchmark.kt
@@ -16,8 +16,6 @@
package androidx.compose.benchmark
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
import androidx.compose.Composable
import androidx.compose.Composer
import androidx.compose.FrameManager
@@ -77,11 +75,13 @@
@LargeTest
@RunWith(Parameterized::class)
class SiblingBenchmark(
- val count: Int, val reorder: ReorderType, val identity: IdentityType
-): ComposeBenchmarkBase() {
+ val count: Int,
+ val reorder: ReorderType,
+ val identity: IdentityType
+) : ComposeBenchmarkBase() {
companion object {
@JvmStatic
- @Parameterized.Parameters(name="{0}_{1}_{2}")
+ @Parameterized.Parameters(name = "{0}_{1}_{2}")
fun data(): Collection<Array<Any>> {
val counts = listOf(100)
val reorders = ReorderType.values()
@@ -109,7 +109,7 @@
val random = Random(0)
measureRecompose {
compose {
- SiblingManagement(identity=identity, items=items.value)
+ SiblingManagement(identity = identity, items = items.value)
}
update {
items.value = items.value.update(reorder, random) { Item(it + 1) }
@@ -117,7 +117,6 @@
}
}
}
-
}
// NOTE: remove when SAM conversion works in IR
@@ -129,5 +128,4 @@
})
}
-
@Model private class ValueHolder<T>(var value: T)
\ No newline at end of file
diff --git a/navigation/benchmark/build.gradle b/navigation/benchmark/build.gradle
index ebb659b..0a308dd 100644
--- a/navigation/benchmark/build.gradle
+++ b/navigation/benchmark/build.gradle
@@ -25,7 +25,7 @@
}
dependencies {
- androidTestImplementation(project(":benchmark:benchmark-common"))
+ androidTestImplementation(project(":benchmark:benchmark-junit4"))
androidTestImplementation(project(":navigation:navigation-runtime"))
androidTestImplementation(project(":navigation:navigation-testing"))
androidTestImplementation(JUNIT)
diff --git a/navigation/benchmark/src/androidTest/java/androidx/navigation/NavInflaterBenchmark.kt b/navigation/benchmark/src/androidTest/java/androidx/navigation/NavInflaterBenchmark.kt
index 09b55d4..9ff4684 100644
--- a/navigation/benchmark/src/androidTest/java/androidx/navigation/NavInflaterBenchmark.kt
+++ b/navigation/benchmark/src/androidTest/java/androidx/navigation/NavInflaterBenchmark.kt
@@ -16,8 +16,8 @@
package androidx.navigation
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
+import androidx.benchmark.junit4.BenchmarkRule
+import androidx.benchmark.junit4.measureRepeated
import androidx.navigation.testing.TestNavigatorProvider
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
diff --git a/recyclerview/recyclerview-benchmark/build.gradle b/recyclerview/recyclerview-benchmark/build.gradle
index 9757829..985934e 100644
--- a/recyclerview/recyclerview-benchmark/build.gradle
+++ b/recyclerview/recyclerview-benchmark/build.gradle
@@ -24,7 +24,7 @@
dependencies {
androidTestImplementation(project(":appcompat"))
androidTestImplementation(project(":recyclerview:recyclerview"))
- androidTestImplementation(project(":benchmark:benchmark-common"))
+ androidTestImplementation(project(":benchmark:benchmark-junit4"))
androidTestImplementation(JUNIT)
androidTestImplementation(ANDROIDX_TEST_EXT_JUNIT)
androidTestImplementation(ANDROIDX_TEST_CORE)
diff --git a/recyclerview/recyclerview-benchmark/src/androidTest/java/androidx/recyclerview/benchmark/ScrollBenchmark.kt b/recyclerview/recyclerview-benchmark/src/androidTest/java/androidx/recyclerview/benchmark/ScrollBenchmark.kt
index 2dec083..8acf597 100644
--- a/recyclerview/recyclerview-benchmark/src/androidTest/java/androidx/recyclerview/benchmark/ScrollBenchmark.kt
+++ b/recyclerview/recyclerview-benchmark/src/androidTest/java/androidx/recyclerview/benchmark/ScrollBenchmark.kt
@@ -20,8 +20,8 @@
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
+import androidx.benchmark.junit4.BenchmarkRule
+import androidx.benchmark.junit4.measureRepeated
import androidx.recyclerview.benchmark.test.R
import androidx.recyclerview.widget.RecyclerView
import androidx.test.annotation.UiThreadTest
diff --git a/room/benchmark/build.gradle b/room/benchmark/build.gradle
index de01cb4..966d074 100644
--- a/room/benchmark/build.gradle
+++ b/room/benchmark/build.gradle
@@ -30,7 +30,7 @@
androidTestImplementation(project(":sqlite:sqlite"))
androidTestImplementation(project(":sqlite:sqlite-framework"))
androidTestImplementation(ARCH_CORE_RUNTIME)
- androidTestImplementation(project(":benchmark:benchmark-common"))
+ androidTestImplementation(project(":benchmark:benchmark-junit4"))
androidTestImplementation(RX_JAVA)
androidTestImplementation(JUNIT)
androidTestImplementation(ANDROIDX_TEST_EXT_JUNIT)
diff --git a/room/benchmark/src/androidTest/java/androidx/room/benchmark/InvalidationTrackerBenchmark.kt b/room/benchmark/src/androidTest/java/androidx/room/benchmark/InvalidationTrackerBenchmark.kt
index 7537d99..861da78 100644
--- a/room/benchmark/src/androidTest/java/androidx/room/benchmark/InvalidationTrackerBenchmark.kt
+++ b/room/benchmark/src/androidTest/java/androidx/room/benchmark/InvalidationTrackerBenchmark.kt
@@ -17,8 +17,8 @@
package androidx.room.benchmark
import android.os.Build
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
+import androidx.benchmark.junit4.BenchmarkRule
+import androidx.benchmark.junit4.measureRepeated
import androidx.room.Dao
import androidx.room.Database
import androidx.room.Entity
diff --git a/room/benchmark/src/androidTest/java/androidx/room/benchmark/RelationBenchmark.kt b/room/benchmark/src/androidTest/java/androidx/room/benchmark/RelationBenchmark.kt
index ac4c427..0fea703 100644
--- a/room/benchmark/src/androidTest/java/androidx/room/benchmark/RelationBenchmark.kt
+++ b/room/benchmark/src/androidTest/java/androidx/room/benchmark/RelationBenchmark.kt
@@ -17,8 +17,8 @@
package androidx.room.benchmark
import android.os.Build
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
+import androidx.benchmark.junit4.BenchmarkRule
+import androidx.benchmark.junit4.measureRepeated
import androidx.room.Dao
import androidx.room.Database
import androidx.room.Embedded
diff --git a/settings.gradle b/settings.gradle
index 901e499..e953056 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -60,6 +60,7 @@
includeProject(":asynclayoutinflater", "asynclayoutinflater")
includeProject(":autofill", "autofill")
includeProject(":benchmark:benchmark-common", "benchmark/common")
+includeProject(":benchmark:benchmark-junit4", "benchmark/junit4")
includeProject(":benchmark:benchmark-benchmark", "benchmark/benchmark")
includeProject(":benchmark:benchmark-gradle-plugin", "benchmark/gradle-plugin")
includeProject(":benchmark:integration-tests:startup-benchmark", "benchmark/integration-tests/startup-benchmark")
diff --git a/slices/benchmark/build.gradle b/slices/benchmark/build.gradle
index e00f194..ecb41ad 100644
--- a/slices/benchmark/build.gradle
+++ b/slices/benchmark/build.gradle
@@ -28,7 +28,7 @@
androidTestImplementation(project(":slice-view"))
androidTestImplementation(project(":slice-core"))
androidTestImplementation(project(":slice-builders"))
- androidTestImplementation(project(":benchmark:benchmark-common"))
+ androidTestImplementation(project(":benchmark:benchmark-junit4"))
androidTestImplementation(JUNIT)
androidTestImplementation(ANDROIDX_TEST_EXT_JUNIT)
androidTestImplementation(ANDROIDX_TEST_CORE)
diff --git a/slices/benchmark/src/androidTest/java/androidx/slice/SliceSerializeMetrics.java b/slices/benchmark/src/androidTest/java/androidx/slice/SliceSerializeMetrics.java
index 0b26fbd..de9e87a 100644
--- a/slices/benchmark/src/androidTest/java/androidx/slice/SliceSerializeMetrics.java
+++ b/slices/benchmark/src/androidTest/java/androidx/slice/SliceSerializeMetrics.java
@@ -32,8 +32,8 @@
import android.graphics.Canvas;
import android.net.Uri;
-import androidx.benchmark.BenchmarkRule;
import androidx.benchmark.BenchmarkState;
+import androidx.benchmark.junit4.BenchmarkRule;
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.benchmark.test.R;
import androidx.slice.core.SliceHints;
diff --git a/slices/benchmark/src/androidTest/java/androidx/slice/SliceViewMetrics.java b/slices/benchmark/src/androidTest/java/androidx/slice/SliceViewMetrics.java
index 43143e1..05482e8 100644
--- a/slices/benchmark/src/androidTest/java/androidx/slice/SliceViewMetrics.java
+++ b/slices/benchmark/src/androidTest/java/androidx/slice/SliceViewMetrics.java
@@ -20,8 +20,8 @@
import android.content.Context;
import android.net.Uri;
-import androidx.benchmark.BenchmarkRule;
import androidx.benchmark.BenchmarkState;
+import androidx.benchmark.junit4.BenchmarkRule;
import androidx.slice.widget.SliceView;
import androidx.test.annotation.UiThreadTest;
import androidx.test.core.app.ApplicationProvider;
diff --git a/ui/integration-tests/benchmark/build.gradle b/ui/integration-tests/benchmark/build.gradle
index 6505a7d..43ecf2c 100644
--- a/ui/integration-tests/benchmark/build.gradle
+++ b/ui/integration-tests/benchmark/build.gradle
@@ -29,7 +29,7 @@
dependencies {
kotlinPlugin project(path: ":compose:compose-compiler", configuration: "embeddablePlugin")
implementation(project(":ui:integration-tests:test"))
- implementation(project(":benchmark:benchmark-common"))
+ implementation(project(":benchmark:benchmark-junit4"))
implementation(project(":compose:compose-runtime"))
implementation(KOTLIN_COMPOSE_STDLIB)
implementation(JUNIT)
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/CheckboxesInRowsBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/CheckboxesInRowsBenchmark.kt
index 07b19a1..58e7938 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/CheckboxesInRowsBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/CheckboxesInRowsBenchmark.kt
@@ -17,7 +17,7 @@
package androidx.ui.benchmark.test
import android.app.Activity
-import androidx.benchmark.BenchmarkRule
+import androidx.benchmark.junit4.BenchmarkRule
import androidx.test.filters.LargeTest
import androidx.test.rule.ActivityTestRule
import androidx.ui.benchmark.measureDrawPerf
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/RectsInColumnBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/RectsInColumnBenchmark.kt
index b63e246..85a5559 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/RectsInColumnBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/RectsInColumnBenchmark.kt
@@ -17,7 +17,7 @@
package androidx.ui.benchmark.test
import android.app.Activity
-import androidx.benchmark.BenchmarkRule
+import androidx.benchmark.junit4.BenchmarkRule
import androidx.test.filters.LargeTest
import androidx.test.rule.ActivityTestRule
import androidx.ui.benchmark.measureDrawPerf
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/RectsInColumnSharedModelBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/RectsInColumnSharedModelBenchmark.kt
index d7af970..17a739a 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/RectsInColumnSharedModelBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/RectsInColumnSharedModelBenchmark.kt
@@ -17,7 +17,7 @@
package androidx.ui.benchmark.test
import android.app.Activity
-import androidx.benchmark.BenchmarkRule
+import androidx.benchmark.junit4.BenchmarkRule
import androidx.test.filters.LargeTest
import androidx.test.rule.ActivityTestRule
import androidx.ui.benchmark.measureDrawPerf
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/view/AndroidCheckboxesInLinearLayoutBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/view/AndroidCheckboxesInLinearLayoutBenchmark.kt
index b178a30..d431b29 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/view/AndroidCheckboxesInLinearLayoutBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/view/AndroidCheckboxesInLinearLayoutBenchmark.kt
@@ -17,7 +17,7 @@
package androidx.ui.benchmark.test.view
import android.app.Activity
-import androidx.benchmark.BenchmarkRule
+import androidx.benchmark.junit4.BenchmarkRule
import androidx.test.filters.LargeTest
import androidx.test.rule.ActivityTestRule
import androidx.ui.benchmark.measureDrawPerf
diff --git a/ui/integration-tests/benchmark/src/main/java/androidx/ui/benchmark/BenchmarksExtensions.kt b/ui/integration-tests/benchmark/src/main/java/androidx/ui/benchmark/BenchmarksExtensions.kt
index c66ef72..fefbde1 100644
--- a/ui/integration-tests/benchmark/src/main/java/androidx/ui/benchmark/BenchmarksExtensions.kt
+++ b/ui/integration-tests/benchmark/src/main/java/androidx/ui/benchmark/BenchmarksExtensions.kt
@@ -18,8 +18,8 @@
import android.app.Activity
import android.view.View
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
+import androidx.benchmark.junit4.BenchmarkRule
+import androidx.benchmark.junit4.measureRepeated
import androidx.compose.disposeComposition
import androidx.ui.test.AndroidTestCase
import androidx.ui.test.ComposeTestCase
diff --git a/ui/settings.gradle b/ui/settings.gradle
index ffc9a88..75431ad 100644
--- a/ui/settings.gradle
+++ b/ui/settings.gradle
@@ -21,6 +21,7 @@
includeProject(":annotation:annotation-sampled", "../annotation/annotation-sampled")
includeProject(":benchmark:benchmark-common", "../benchmark/common")
+includeProject(":benchmark:benchmark-junit4", "../benchmark/junit4")
includeProject(":compose:compose-compiler", "../compose/compose-compiler")
includeProject(":compose:compose-compiler-hosted", "../compose/compose-compiler-hosted")
includeProject(":compose:compose-compiler-hosted:integration-tests", "../compose/compose-compiler-hosted/integration-tests")
diff --git a/ui/ui-layout/build.gradle b/ui/ui-layout/build.gradle
index 31b4c47..d467d30 100644
--- a/ui/ui-layout/build.gradle
+++ b/ui/ui-layout/build.gradle
@@ -44,7 +44,7 @@
testImplementation(ANDROIDX_TEST_RUNNER)
testImplementation(JUNIT)
- androidTestImplementation project(":benchmark:benchmark-common")
+ androidTestImplementation project(":benchmark:benchmark-junit4")
androidTestImplementation project(":ui:ui-platform")
androidTestImplementation(ANDROIDX_TEST_RULES)
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ScrollerPerformance.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ScrollerPerformance.kt
index 3efac80..652694d 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ScrollerPerformance.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ScrollerPerformance.kt
@@ -17,8 +17,8 @@
package androidx.ui.layout.test
import android.view.View
-import androidx.benchmark.BenchmarkRule
-import androidx.benchmark.measureRepeated
+import androidx.benchmark.junit4.BenchmarkRule
+import androidx.benchmark.junit4.measureRepeated
import androidx.compose.Composable
import androidx.compose.CompositionContext
import androidx.compose.FrameManager