Move perfetto capture and protos to benchmark-common
Test: ./gradlew benchmark:benchmark-common:cC benchmark:benchmark-macro:cC benchmark:benchmark-macro-junit4:cC benchmark:benchmark-junit4:cC
Bug: 196115387
Bug: 145598917
Relnote: N/A
PerfettoTraceProcessor and its binary will stay in benchmark-macro.
Moves PerfettoRule to benchmark-junit, so that microbenchmarks don't
need to depend on benchmark-macro-junit4. Eventually, this
functionality can be merged into BenchmarkRule, as long as
in-process/app tag tracing is configurable, and off by
default. UserspaceTracing will enable us to still capture
BenchmarkState lifecycle events, like different modes (warmup /
measure / allocation count).
This unblocks raising the minAPI of Macrobench to the long-term goal
of API 21, which is the lowest that can support shell commands, as
well as perfetto capture.
This change also moves a few supporting classes, such as DeviceInfo
and ConfigurationError, which were always intended to gradually
replace benchmark-common's error / device state querying. This starts
that process.
As testutils-ktx is used by benchmark-common now, add to all project
config flavors.
Change-Id: I6559b6735d0106e38ec5d8eaeddcac9297d0c431
diff --git a/benchmark/benchmark-common/api/current.txt b/benchmark/benchmark-common/api/current.txt
index 1874053..7410e3f 100644
--- a/benchmark/benchmark-common/api/current.txt
+++ b/benchmark/benchmark-common/api/current.txt
@@ -29,11 +29,27 @@
public static final class BenchmarkState.Companion {
}
+ public final class ConfigurationErrorKt {
+ }
+
public final class MetricNameUtilsKt {
}
public final class ProfilerKt {
}
+ public final class UserspaceTracingKt {
+ }
+
+}
+
+package androidx.benchmark.perfetto {
+
+ public final class PerfettoConfigKt {
+ }
+
+ public final class UiStateKt {
+ }
+
}
diff --git a/benchmark/benchmark-common/api/public_plus_experimental_current.txt b/benchmark/benchmark-common/api/public_plus_experimental_current.txt
index 39d1008..db914e9 100644
--- a/benchmark/benchmark-common/api/public_plus_experimental_current.txt
+++ b/benchmark/benchmark-common/api/public_plus_experimental_current.txt
@@ -34,11 +34,27 @@
@kotlin.Experimental @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget) public static @interface BenchmarkState.Companion.ExperimentalExternalReport {
}
+ public final class ConfigurationErrorKt {
+ }
+
public final class MetricNameUtilsKt {
}
public final class ProfilerKt {
}
+ public final class UserspaceTracingKt {
+ }
+
+}
+
+package androidx.benchmark.perfetto {
+
+ public final class PerfettoConfigKt {
+ }
+
+ public final class UiStateKt {
+ }
+
}
diff --git a/benchmark/benchmark-common/api/restricted_current.txt b/benchmark/benchmark-common/api/restricted_current.txt
index 39bcc5a..ac28e4c 100644
--- a/benchmark/benchmark-common/api/restricted_current.txt
+++ b/benchmark/benchmark-common/api/restricted_current.txt
@@ -31,11 +31,27 @@
public static final class BenchmarkState.Companion {
}
+ public final class ConfigurationErrorKt {
+ }
+
public final class MetricNameUtilsKt {
}
public final class ProfilerKt {
}
+ public final class UserspaceTracingKt {
+ }
+
+}
+
+package androidx.benchmark.perfetto {
+
+ public final class PerfettoConfigKt {
+ }
+
+ public final class UiStateKt {
+ }
+
}
diff --git a/benchmark/benchmark-common/build.gradle b/benchmark/benchmark-common/build.gradle
index 6d47166..97d492f 100644
--- a/benchmark/benchmark-common/build.gradle
+++ b/benchmark/benchmark-common/build.gradle
@@ -16,12 +16,47 @@
import androidx.build.LibraryGroups
import androidx.build.Publish
+import androidx.build.SupportConfigKt
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("AndroidXPlugin")
id("com.android.library")
id("kotlin-android")
+ id("com.squareup.wire")
+}
+
+android {
+ sourceSets {
+ main.assets.srcDirs += new File(
+ SupportConfigKt.getPrebuiltsRoot(project),
+ "androidx/traceprocessor/perfetto"
+ )
+ main.assets.srcDirs += new File(
+ SupportConfigKt.getPrebuiltsRoot(project),
+ "androidx/traceprocessor/traced"
+ )
+ main.assets.srcDirs += new File(
+ SupportConfigKt.getPrebuiltsRoot(project),
+ "androidx/traceprocessor/traced_probes"
+ )
+ androidTest.assets.srcDirs += new File(
+ SupportConfigKt.getPrebuiltsRoot(project),
+ "androidx/traceprocessor/testdata"
+ )
+ }
+}
+
+wire {
+ kotlin {}
+
+ // prune unused config components which have deprecated fields
+ prune 'perfetto.protos.TraceConfig.IncidentReportConfig'
+ prune 'perfetto.protos.ProcessStatsConfig.Quirks'
+
+ sourcePath {
+ srcDir 'src/main/proto'
+ }
}
dependencies {
@@ -30,6 +65,7 @@
api("androidx.annotation:annotation-experimental:1.0.0")
implementation("androidx.tracing:tracing-ktx:1.0.0")
implementation(libs.testMonitor)
+ implementation(libs.wireRuntime)
androidTestImplementation(libs.testRules)
androidTestImplementation(libs.testExtJunit)
diff --git a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/ConfigurationErrorTest.kt b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ConfigurationErrorTest.kt
similarity index 98%
rename from benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/ConfigurationErrorTest.kt
rename to benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ConfigurationErrorTest.kt
index 0889c6a..7342c236 100644
--- a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/ConfigurationErrorTest.kt
+++ b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ConfigurationErrorTest.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package androidx.benchmark.macro
+package androidx.benchmark
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
diff --git a/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/Packages.kt b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/Packages.kt
new file mode 100644
index 0000000..28585a6
--- /dev/null
+++ b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/Packages.kt
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2021 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
+
+import androidx.test.platform.app.InstrumentationRegistry
+
+object Packages {
+ val TEST: String = InstrumentationRegistry.getInstrumentation()
+ .context
+ .packageName
+}
diff --git a/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ShellBehaviorTest.kt b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ShellBehaviorTest.kt
index 3285e4c..5f4ccbc 100644
--- a/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ShellBehaviorTest.kt
+++ b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ShellBehaviorTest.kt
@@ -20,7 +20,6 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import androidx.test.filters.SdkSuppress
-import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Test
import org.junit.runner.RunWith
import kotlin.test.assertEquals
@@ -35,12 +34,10 @@
@SdkSuppress(minSdkVersion = 21)
@RunWith(AndroidJUnit4::class)
class ShellBehaviorTest {
- private val packageName = InstrumentationRegistry.getInstrumentation().context.packageName
-
@Test
fun pidof() {
// Should only be one process - this one!
- val pidofString = Shell.executeCommand("pidof $packageName").trim()
+ val pidofString = Shell.executeCommand("pidof ${Packages.TEST}").trim()
when {
Build.VERSION.SDK_INT < 23 -> {
@@ -76,7 +73,7 @@
// ps -A should work - expect several processes including this one
val processes = output.split("\n")
assertTrue(processes.size > 5)
- assertTrue(processes.any { it.endsWith(packageName) })
+ assertTrue(processes.any { it.endsWith(Packages.TEST) })
}
}
}
diff --git a/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ShellTest.kt b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ShellTest.kt
index b603559..d02717f 100644
--- a/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ShellTest.kt
+++ b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ShellTest.kt
@@ -20,7 +20,6 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SdkSuppress
import androidx.test.filters.SmallTest
-import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert
import org.junit.Assume.assumeTrue
import org.junit.Test
@@ -211,8 +210,7 @@
@Test
fun isPackageAlive() {
// this package is certainly alive...
- val packageName = InstrumentationRegistry.getInstrumentation().context.packageName
- assertNotNull(Shell.isPackageAlive(packageName))
+ assertNotNull(Shell.isPackageAlive(Packages.TEST))
// this made up one shouldn't be
assertNotNull(Shell.isPackageAlive("com.notalive.package.notarealapp"))
diff --git a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/UserspaceTracingTest.kt b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/UserspaceTracingTest.kt
similarity index 88%
rename from benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/UserspaceTracingTest.kt
rename to benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/UserspaceTracingTest.kt
index d1d5423..73f5067 100644
--- a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/UserspaceTracingTest.kt
+++ b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/UserspaceTracingTest.kt
@@ -14,10 +14,11 @@
* limitations under the License.
*/
-package androidx.benchmark.macro
+package androidx.benchmark
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
+import androidx.test.platform.app.InstrumentationRegistry
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
@@ -27,6 +28,7 @@
import perfetto.protos.TracePacket
import perfetto.protos.TrackDescriptor
import perfetto.protos.TrackEvent
+import java.io.File
import kotlin.test.assertNotNull
@RunWith(AndroidJUnit4::class)
@@ -111,3 +113,15 @@
}
}
}
+
+@Suppress("SameParameterValue")
+internal fun createTempFileFromAsset(prefix: String, suffix: String): File {
+ val file = File.createTempFile(prefix, suffix, Outputs.dirUsableByAppAndShell)
+ InstrumentationRegistry
+ .getInstrumentation()
+ .context
+ .assets
+ .open(prefix + suffix)
+ .copyTo(file.outputStream())
+ return file
+}
\ No newline at end of file
diff --git a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/AtraceTagTest.kt b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/perfetto/AtraceTagTest.kt
similarity index 87%
rename from benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/AtraceTagTest.kt
rename to benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/perfetto/AtraceTagTest.kt
index 3f91f11..88f8578 100644
--- a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/AtraceTagTest.kt
+++ b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/perfetto/AtraceTagTest.kt
@@ -14,14 +14,12 @@
* limitations under the License.
*/
-package androidx.benchmark.macro.perfetto
+package androidx.benchmark.perfetto
import androidx.benchmark.Shell
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SdkSuppress
import androidx.test.filters.SmallTest
-import androidx.test.platform.app.InstrumentationRegistry
-import androidx.test.uiautomator.UiDevice
import org.junit.Assume
import org.junit.Test
import org.junit.runner.RunWith
@@ -33,17 +31,16 @@
@SdkSuppress(minSdkVersion = 21)
@SmallTest
class AtraceTagTest {
- private val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
private val shellSessionRooted = Shell.isSessionRooted()
@Test
fun atraceListCategories_readable() {
- val results = device.executeShellCommand("atrace --list_categories")
+ val results = Shell.executeCommand("atrace --list_categories")
assertNotEquals("", results)
}
private fun getActualSupportedTags(): Set<String> {
- val results = device.executeShellCommand("atrace --list_categories")
+ val results = Shell.executeCommand("atrace --list_categories")
assertNotEquals("", results)
val actualSupportedTags = results
diff --git a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/PerfettoConfigTest.kt b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/perfetto/PerfettoConfigTest.kt
similarity index 97%
rename from benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/PerfettoConfigTest.kt
rename to benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/perfetto/PerfettoConfigTest.kt
index 365cf76..45f983d 100644
--- a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/PerfettoConfigTest.kt
+++ b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/perfetto/PerfettoConfigTest.kt
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package androidx.benchmark.macro.perfetto
+package androidx.benchmark.perfetto
-import androidx.benchmark.macro.Packages
+import androidx.benchmark.Packages
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SdkSuppress
import androidx.test.filters.SmallTest
diff --git a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/UiStateTest.kt b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/perfetto/UiStateTest.kt
similarity index 87%
rename from benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/UiStateTest.kt
rename to benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/perfetto/UiStateTest.kt
index 9d582fd..5199c56 100644
--- a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/UiStateTest.kt
+++ b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/perfetto/UiStateTest.kt
@@ -14,12 +14,11 @@
* limitations under the License.
*/
-package androidx.benchmark.macro.perfetto
+package androidx.benchmark.perfetto
-import androidx.benchmark.Outputs
+import androidx.benchmark.createTempFileFromAsset
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
-import androidx.test.platform.app.InstrumentationRegistry
import okio.ByteString
import org.junit.Assert.assertTrue
import org.junit.Test
@@ -118,15 +117,3 @@
assertTrue(finalSize > initialSize * 0.95f)
}
}
-
-@Suppress("SameParameterValue")
-internal fun createTempFileFromAsset(prefix: String, suffix: String): File {
- val file = File.createTempFile(prefix, suffix, Outputs.dirUsableByAppAndShell)
- InstrumentationRegistry
- .getInstrumentation()
- .context
- .assets
- .open(prefix + suffix)
- .copyTo(file.outputStream())
- return file
-}
\ No newline at end of file
diff --git a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/ConfigurationError.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/ConfigurationError.kt
similarity index 91%
rename from benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/ConfigurationError.kt
rename to benchmark/benchmark-common/src/main/java/androidx/benchmark/ConfigurationError.kt
index 0758048..ab498d3 100644
--- a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/ConfigurationError.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/ConfigurationError.kt
@@ -14,12 +14,17 @@
* limitations under the License.
*/
-package androidx.benchmark.macro
+package androidx.benchmark
+
+import androidx.annotation.RestrictTo
/**
* Represents an error in configuration of a benchmark.
+ *
+ * @suppress
*/
-internal data class ConfigurationError(
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+data class ConfigurationError(
/**
* All-caps, publicly visible ID for the error.
*
@@ -74,7 +79,9 @@
)
}
-internal fun conditionalError(
+/** @suppress */
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+fun conditionalError(
hasError: Boolean,
id: String,
summary: String,
@@ -96,8 +103,11 @@
/**
* Throw an AssertionError if the list contains an unsuppressed error, and return either a
* SuppressionState if errors are suppressed, or null otherwise.
+ *
+ * @suppress
*/
-internal fun List<ConfigurationError>.checkAndGetSuppressionState(
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+fun List<ConfigurationError>.checkAndGetSuppressionState(
suppressedErrorIds: Set<String>,
): ConfigurationError.SuppressionState? {
val (suppressed, unsuppressed) = partition {
diff --git a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/DeviceInfo.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/DeviceInfo.kt
similarity index 97%
rename from benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/DeviceInfo.kt
rename to benchmark/benchmark-common/src/main/java/androidx/benchmark/DeviceInfo.kt
index a93a8b7..1378bad 100644
--- a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/DeviceInfo.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/DeviceInfo.kt
@@ -14,16 +14,18 @@
* limitations under the License.
*/
-package androidx.benchmark.macro
+package androidx.benchmark
import android.content.Intent
import android.content.IntentFilter
import android.os.BatteryManager
import android.os.Build
+import androidx.annotation.RestrictTo
import androidx.test.platform.app.InstrumentationRegistry
import java.io.File
-internal object DeviceInfo {
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+object DeviceInfo {
val isEmulator = Build.FINGERPRINT.startsWith("generic") ||
Build.FINGERPRINT.startsWith("unknown") ||
Build.MODEL.contains("google_sdk") ||
diff --git a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/UserspaceTracing.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/UserspaceTracing.kt
similarity index 89%
rename from benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/UserspaceTracing.kt
rename to benchmark/benchmark-common/src/main/java/androidx/benchmark/UserspaceTracing.kt
index 17f03b2..b27c1ed 100644
--- a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/UserspaceTracing.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/UserspaceTracing.kt
@@ -14,8 +14,9 @@
* limitations under the License.
*/
-package androidx.benchmark.macro
+package androidx.benchmark
+import androidx.annotation.RestrictTo
import perfetto.protos.Trace
import perfetto.protos.TracePacket
import perfetto.protos.TrackDescriptor
@@ -30,8 +31,11 @@
* After trace processing, the extra events (before _and_ after the measureBlock section of a
* benchmark) can be added to the trace by calling [commitToTrace], and appending that to the
* trace on-disk.
+ *
+ * @suppress
*/
-internal object UserspaceTracing {
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+object UserspaceTracing {
/**
* All events emitted by the benchmark annotation should have the same value.
* the value needs to not conflict with any sequence id emitted in the trace.
@@ -90,7 +94,7 @@
return Trace(capturedEvents)
}
- private fun startSection(label: String) {
+ fun startSection(label: String) {
events.add(
TracePacket(
timestamp = System.nanoTime(),
@@ -106,7 +110,7 @@
)
}
- private fun endSection() {
+ fun endSection() {
events.add(
TracePacket(
timestamp = System.nanoTime(),
@@ -119,17 +123,15 @@
)
)
}
-
- inline fun <T> trace(label: String, block: () -> T): T {
- startSection(label)
- return try {
- block()
- } finally {
- endSection()
- }
- }
}
-internal inline fun <T> userspaceTrace(label: String, block: () -> T): T {
- return UserspaceTracing.trace(label, block)
+/** @suppress */
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+inline fun <T> userspaceTrace(label: String, block: () -> T): T {
+ UserspaceTracing.startSection(label)
+ return try {
+ block()
+ } finally {
+ UserspaceTracing.endSection()
+ }
}
diff --git a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/AtraceTag.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/AtraceTag.kt
similarity index 97%
rename from benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/AtraceTag.kt
rename to benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/AtraceTag.kt
index ef21283..31e6a21 100644
--- a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/AtraceTag.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/AtraceTag.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package androidx.benchmark.macro.perfetto
+package androidx.benchmark.perfetto
import android.os.Build
diff --git a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoCapture.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/PerfettoCapture.kt
similarity index 95%
rename from benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoCapture.kt
rename to benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/PerfettoCapture.kt
index c286b81..b8c6474 100644
--- a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoCapture.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/PerfettoCapture.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 The Android Open Source Project
+ * Copyright 2021 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.
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package androidx.benchmark.macro.perfetto
+package androidx.benchmark.perfetto
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.annotation.RestrictTo
import androidx.benchmark.Outputs
-import androidx.benchmark.macro.userspaceTrace
+import androidx.benchmark.userspaceTrace
import java.io.File
/**
diff --git a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoCaptureWrapper.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/PerfettoCaptureWrapper.kt
similarity index 94%
rename from benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoCaptureWrapper.kt
rename to benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/PerfettoCaptureWrapper.kt
index 4c63fb6a..11ebeb0 100644
--- a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoCaptureWrapper.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/PerfettoCaptureWrapper.kt
@@ -14,11 +14,12 @@
* limitations under the License.
*/
-package androidx.benchmark.macro.perfetto
+package androidx.benchmark.perfetto
import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
+import androidx.annotation.RestrictTo
import androidx.benchmark.Outputs
import androidx.benchmark.Outputs.dateToFileName
import androidx.benchmark.PropOverride
@@ -26,7 +27,8 @@
/**
* Wrapper for [PerfettoCapture] which does nothing below L.
*/
-internal class PerfettoCaptureWrapper {
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+class PerfettoCaptureWrapper {
private var capture: PerfettoCapture? = null
private val TRACE_ENABLE_PROP = "persist.traced.enable"
diff --git a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoConfig.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/PerfettoConfig.kt
similarity index 96%
rename from benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoConfig.kt
rename to benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/PerfettoConfig.kt
index 747e58f..34adfb4 100644
--- a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoConfig.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/PerfettoConfig.kt
@@ -14,10 +14,11 @@
* limitations under the License.
*/
-package androidx.benchmark.macro.perfetto
+package androidx.benchmark.perfetto
import android.os.Build
import androidx.annotation.RequiresApi
+import androidx.annotation.RestrictTo
import androidx.benchmark.Shell
import perfetto.protos.DataSourceConfig
import perfetto.protos.FtraceConfig
@@ -134,9 +135,12 @@
/**
* Global config for perfetto.
*
- * Eventually, this should be configurable.
+ * Eventually, this should be more configurable.
+ *
+ * @suppress
*/
-internal fun perfettoConfig(
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+fun perfettoConfig(
atraceApps: List<String>
) = TraceConfig(
buffers = listOf(
diff --git a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoHelper.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/PerfettoHelper.kt
similarity index 98%
rename from benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoHelper.kt
rename to benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/PerfettoHelper.kt
index 4606a25..4cee2fc 100644
--- a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoHelper.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/PerfettoHelper.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package androidx.benchmark.macro.perfetto
+package androidx.benchmark.perfetto
import android.os.Build
import android.os.SystemClock
@@ -22,8 +22,8 @@
import androidx.annotation.RequiresApi
import androidx.annotation.RestrictTo
import androidx.benchmark.Shell
-import androidx.benchmark.macro.DeviceInfo.deviceSummaryString
-import androidx.benchmark.macro.userspaceTrace
+import androidx.benchmark.DeviceInfo.deviceSummaryString
+import androidx.benchmark.userspaceTrace
import androidx.test.platform.app.InstrumentationRegistry
import org.jetbrains.annotations.TestOnly
import java.io.File
@@ -348,7 +348,7 @@
return true
}
- internal companion object {
+ companion object {
internal const val LOG_TAG = "PerfettoCapture"
const val LOWEST_BUNDLED_VERSION_SUPPORTED = 29
@@ -418,7 +418,7 @@
createExecutable(PERFETTO)
}
- internal fun createExecutable(tool: String): String {
+ fun createExecutable(tool: String): String {
userspaceTrace("create executable: $tool") {
if (!isAbiSupported()) {
throw IllegalStateException(
diff --git a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/UiState.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/UiState.kt
similarity index 85%
rename from benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/UiState.kt
rename to benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/UiState.kt
index 33bf7de..bcd94d2 100644
--- a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/UiState.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/perfetto/UiState.kt
@@ -14,8 +14,9 @@
* limitations under the License.
*/
-package androidx.benchmark.macro.perfetto
+package androidx.benchmark.perfetto
+import androidx.annotation.RestrictTo
import perfetto.protos.Trace
import perfetto.protos.TracePacket
import perfetto.protos.UiState
@@ -25,7 +26,8 @@
* Convenience for UiState construction with specified package
*/
@Suppress("FunctionName") // constructor convenience
-internal fun UiState(
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+fun UiState(
timelineStart: Long?,
timelineEnd: Long?,
highlightPackage: String?
@@ -37,7 +39,8 @@
}
)
-internal fun File.appendUiState(state: UiState) {
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+fun File.appendUiState(state: UiState) {
val traceToAppend = Trace(packet = listOf(TracePacket(ui_state = state)))
appendBytes(traceToAppend.encode())
}
diff --git a/benchmark/benchmark-macro/src/main/java/perfetto/protos/package-info.java b/benchmark/benchmark-common/src/main/java/perfetto/protos/package-info.java
similarity index 84%
rename from benchmark/benchmark-macro/src/main/java/perfetto/protos/package-info.java
rename to benchmark/benchmark-common/src/main/java/perfetto/protos/package-info.java
index 4654d20..fd5614d 100644
--- a/benchmark/benchmark-macro/src/main/java/perfetto/protos/package-info.java
+++ b/benchmark/benchmark-common/src/main/java/perfetto/protos/package-info.java
@@ -15,14 +15,14 @@
*/
/**
- * Hide the perfetto.protos package, as it's an implementation detail of benchmark.macro
+ * Hide the perfetto.protos package, as it's an implementation detail of benchmark
*
- * Note: other attempts to use these protos in the macrobench process will clash with our
+ * Note: other attempts to use these protos in a benchmark process may clash with our
* definitions. If this becomes an issue, we can move ours to a separate, internal package.
*
* @hide
*/
-@RestrictTo(RestrictTo.Scope.LIBRARY)
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
package perfetto.protos;
import androidx.annotation.RestrictTo;
diff --git a/benchmark/benchmark-macro/src/main/proto/perfetto_config.proto b/benchmark/benchmark-common/src/main/proto/perfetto_config.proto
similarity index 100%
rename from benchmark/benchmark-macro/src/main/proto/perfetto_config.proto
rename to benchmark/benchmark-common/src/main/proto/perfetto_config.proto
diff --git a/benchmark/benchmark-macro/src/main/proto/perfetto_trace.proto b/benchmark/benchmark-common/src/main/proto/perfetto_trace.proto
similarity index 100%
rename from benchmark/benchmark-macro/src/main/proto/perfetto_trace.proto
rename to benchmark/benchmark-common/src/main/proto/perfetto_trace.proto
diff --git a/benchmark/benchmark-junit4/api/current.txt b/benchmark/benchmark-junit4/api/current.txt
index 873f105..bb78174 100644
--- a/benchmark/benchmark-junit4/api/current.txt
+++ b/benchmark/benchmark-junit4/api/current.txt
@@ -19,5 +19,8 @@
method public static inline void measureRepeated(androidx.benchmark.junit4.BenchmarkRule, kotlin.jvm.functions.Function1<? super androidx.benchmark.junit4.BenchmarkRule.Scope,kotlin.Unit> block);
}
+ public final class PerfettoRuleKt {
+ }
+
}
diff --git a/benchmark/benchmark-junit4/api/public_plus_experimental_current.txt b/benchmark/benchmark-junit4/api/public_plus_experimental_current.txt
index 873f105..bb78174 100644
--- a/benchmark/benchmark-junit4/api/public_plus_experimental_current.txt
+++ b/benchmark/benchmark-junit4/api/public_plus_experimental_current.txt
@@ -19,5 +19,8 @@
method public static inline void measureRepeated(androidx.benchmark.junit4.BenchmarkRule, kotlin.jvm.functions.Function1<? super androidx.benchmark.junit4.BenchmarkRule.Scope,kotlin.Unit> block);
}
+ public final class PerfettoRuleKt {
+ }
+
}
diff --git a/benchmark/benchmark-junit4/api/restricted_current.txt b/benchmark/benchmark-junit4/api/restricted_current.txt
index c2d8056..8ffdd9b 100644
--- a/benchmark/benchmark-junit4/api/restricted_current.txt
+++ b/benchmark/benchmark-junit4/api/restricted_current.txt
@@ -20,5 +20,13 @@
method public static inline void measureRepeated(androidx.benchmark.junit4.BenchmarkRule, kotlin.jvm.functions.Function1<? super androidx.benchmark.junit4.BenchmarkRule.Scope,kotlin.Unit> block);
}
+ @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public final class PerfettoRule implements org.junit.rules.TestRule {
+ ctor public PerfettoRule();
+ method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description);
+ }
+
+ public final class PerfettoRuleKt {
+ }
+
}
diff --git a/benchmark/benchmark-junit4/build.gradle b/benchmark/benchmark-junit4/build.gradle
index 11d54c0..cd30ba8 100644
--- a/benchmark/benchmark-junit4/build.gradle
+++ b/benchmark/benchmark-junit4/build.gradle
@@ -40,6 +40,7 @@
implementation("androidx.tracing:tracing-ktx:1.0.0")
api("androidx.annotation:annotation:1.1.0")
+ androidTestImplementation(project(":internal-testutils-ktx"))
androidTestImplementation(libs.testCore)
androidTestImplementation(libs.testExtJunit)
}
diff --git a/benchmark/benchmark-macro-junit4/src/androidTest/java/androidx/benchmark/macro/test/PerfettoRuleTest.kt b/benchmark/benchmark-junit4/src/androidTest/java/androidx/benchmark/junit4/PerfettoRuleTest.kt
similarity index 95%
rename from benchmark/benchmark-macro-junit4/src/androidTest/java/androidx/benchmark/macro/test/PerfettoRuleTest.kt
rename to benchmark/benchmark-junit4/src/androidTest/java/androidx/benchmark/junit4/PerfettoRuleTest.kt
index cb58a02..ab6003a5 100644
--- a/benchmark/benchmark-macro-junit4/src/androidTest/java/androidx/benchmark/macro/test/PerfettoRuleTest.kt
+++ b/benchmark/benchmark-junit4/src/androidTest/java/androidx/benchmark/junit4/PerfettoRuleTest.kt
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package androidx.benchmark.macro.test
+package androidx.benchmark.junit4
import android.os.Build
-import androidx.benchmark.macro.junit4.PerfettoRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.filters.SmallTest
diff --git a/benchmark/benchmark-macro-junit4/src/main/java/androidx/benchmark/macro/junit4/PerfettoRule.kt b/benchmark/benchmark-junit4/src/main/java/androidx/benchmark/junit4/PerfettoRule.kt
similarity index 91%
rename from benchmark/benchmark-macro-junit4/src/main/java/androidx/benchmark/macro/junit4/PerfettoRule.kt
rename to benchmark/benchmark-junit4/src/main/java/androidx/benchmark/junit4/PerfettoRule.kt
index fc36ac4..1c900ee 100644
--- a/benchmark/benchmark-macro-junit4/src/main/java/androidx/benchmark/macro/junit4/PerfettoRule.kt
+++ b/benchmark/benchmark-junit4/src/main/java/androidx/benchmark/junit4/PerfettoRule.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package androidx.benchmark.macro.junit4
+package androidx.benchmark.junit4
import android.os.Build
import android.util.Log
@@ -22,7 +22,8 @@
import androidx.annotation.RestrictTo
import androidx.benchmark.Outputs
import androidx.benchmark.Outputs.dateToFileName
-import androidx.benchmark.macro.perfetto.PerfettoCapture
+import androidx.benchmark.perfetto.PerfettoCapture
+import androidx.benchmark.perfetto.PerfettoHelper
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.rules.TestRule
import org.junit.runner.Description
@@ -57,11 +58,11 @@
description: Description
): Statement = object : Statement() {
override fun evaluate() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ if (Build.VERSION.SDK_INT >= PerfettoHelper.LOWEST_BUNDLED_VERSION_SUPPORTED) {
val prefix = "${description.className}_${description.methodName}"
val suffix = dateToFileName()
val traceName = "${prefix}_$suffix.perfetto-trace"
- PerfettoCapture().recordAndReportFile(traceName) {
+ PerfettoCapture(unbundled = false).recordAndReportFile(traceName) {
base.evaluate()
}
} else {
diff --git a/benchmark/benchmark-macro-junit4/api/current.txt b/benchmark/benchmark-macro-junit4/api/current.txt
index 5d2528d..1c277c8 100644
--- a/benchmark/benchmark-macro-junit4/api/current.txt
+++ b/benchmark/benchmark-macro-junit4/api/current.txt
@@ -10,8 +10,5 @@
method public void measureRepeated(String packageName, java.util.List<? extends androidx.benchmark.macro.Metric> metrics, @IntRange(from=1) int iterations, kotlin.jvm.functions.Function1<? super androidx.benchmark.macro.MacrobenchmarkScope,kotlin.Unit> measureBlock);
}
- public final class PerfettoRuleKt {
- }
-
}
diff --git a/benchmark/benchmark-macro-junit4/api/public_plus_experimental_current.txt b/benchmark/benchmark-macro-junit4/api/public_plus_experimental_current.txt
index 5d2528d..1c277c8 100644
--- a/benchmark/benchmark-macro-junit4/api/public_plus_experimental_current.txt
+++ b/benchmark/benchmark-macro-junit4/api/public_plus_experimental_current.txt
@@ -10,8 +10,5 @@
method public void measureRepeated(String packageName, java.util.List<? extends androidx.benchmark.macro.Metric> metrics, @IntRange(from=1) int iterations, kotlin.jvm.functions.Function1<? super androidx.benchmark.macro.MacrobenchmarkScope,kotlin.Unit> measureBlock);
}
- public final class PerfettoRuleKt {
- }
-
}
diff --git a/benchmark/benchmark-macro-junit4/api/restricted_current.txt b/benchmark/benchmark-macro-junit4/api/restricted_current.txt
index 431728d..1c277c8 100644
--- a/benchmark/benchmark-macro-junit4/api/restricted_current.txt
+++ b/benchmark/benchmark-macro-junit4/api/restricted_current.txt
@@ -10,13 +10,5 @@
method public void measureRepeated(String packageName, java.util.List<? extends androidx.benchmark.macro.Metric> metrics, @IntRange(from=1) int iterations, kotlin.jvm.functions.Function1<? super androidx.benchmark.macro.MacrobenchmarkScope,kotlin.Unit> measureBlock);
}
- @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public final class PerfettoRule implements org.junit.rules.TestRule {
- ctor public PerfettoRule();
- method public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description);
- }
-
- public final class PerfettoRuleKt {
- }
-
}
diff --git a/benchmark/benchmark-macro/api/current.txt b/benchmark/benchmark-macro/api/current.txt
index 5482016..1ee96be0 100644
--- a/benchmark/benchmark-macro/api/current.txt
+++ b/benchmark/benchmark-macro/api/current.txt
@@ -28,9 +28,6 @@
public final class CompilationModeKt {
}
- public final class ConfigurationErrorKt {
- }
-
@RequiresApi(21) public final class FrameTimingMetric extends androidx.benchmark.macro.Metric {
ctor public FrameTimingMetric();
}
@@ -72,18 +69,5 @@
public final class TagKt {
}
- public final class UserspaceTracingKt {
- }
-
-}
-
-package androidx.benchmark.macro.perfetto {
-
- public final class PerfettoConfigKt {
- }
-
- public final class UiStateKt {
- }
-
}
diff --git a/benchmark/benchmark-macro/api/public_plus_experimental_current.txt b/benchmark/benchmark-macro/api/public_plus_experimental_current.txt
index 5482016..1ee96be0 100644
--- a/benchmark/benchmark-macro/api/public_plus_experimental_current.txt
+++ b/benchmark/benchmark-macro/api/public_plus_experimental_current.txt
@@ -28,9 +28,6 @@
public final class CompilationModeKt {
}
- public final class ConfigurationErrorKt {
- }
-
@RequiresApi(21) public final class FrameTimingMetric extends androidx.benchmark.macro.Metric {
ctor public FrameTimingMetric();
}
@@ -72,18 +69,5 @@
public final class TagKt {
}
- public final class UserspaceTracingKt {
- }
-
-}
-
-package androidx.benchmark.macro.perfetto {
-
- public final class PerfettoConfigKt {
- }
-
- public final class UiStateKt {
- }
-
}
diff --git a/benchmark/benchmark-macro/api/restricted_current.txt b/benchmark/benchmark-macro/api/restricted_current.txt
index 21bddb9..3a19a6a 100644
--- a/benchmark/benchmark-macro/api/restricted_current.txt
+++ b/benchmark/benchmark-macro/api/restricted_current.txt
@@ -32,9 +32,6 @@
method @RequiresApi(21) @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public static boolean isSupportedWithVmSettings(androidx.benchmark.macro.CompilationMode);
}
- public final class ConfigurationErrorKt {
- }
-
@RequiresApi(21) public final class FrameTimingMetric extends androidx.benchmark.macro.Metric {
ctor public FrameTimingMetric();
}
@@ -76,18 +73,5 @@
public final class TagKt {
}
- public final class UserspaceTracingKt {
- }
-
-}
-
-package androidx.benchmark.macro.perfetto {
-
- public final class PerfettoConfigKt {
- }
-
- public final class UiStateKt {
- }
-
}
diff --git a/benchmark/benchmark-macro/build.gradle b/benchmark/benchmark-macro/build.gradle
index 640b7cf0..3b22be8 100644
--- a/benchmark/benchmark-macro/build.gradle
+++ b/benchmark/benchmark-macro/build.gradle
@@ -22,7 +22,6 @@
id("AndroidXPlugin")
id("com.android.library")
id("kotlin-android")
- id("com.squareup.wire")
}
android {
@@ -36,18 +35,6 @@
SupportConfigKt.getPrebuiltsRoot(project),
"androidx/traceprocessor/trace_processor_shell"
)
- main.assets.srcDirs += new File(
- SupportConfigKt.getPrebuiltsRoot(project),
- "androidx/traceprocessor/perfetto"
- )
- main.assets.srcDirs += new File(
- SupportConfigKt.getPrebuiltsRoot(project),
- "androidx/traceprocessor/traced"
- )
- main.assets.srcDirs += new File(
- SupportConfigKt.getPrebuiltsRoot(project),
- "androidx/traceprocessor/traced_probes"
- )
androidTest.assets.srcDirs += new File(
SupportConfigKt.getPrebuiltsRoot(project),
"androidx/traceprocessor/testdata"
@@ -55,18 +42,6 @@
}
}
-wire {
- kotlin {}
-
- // prune unused config components which have deprecated fields
- prune 'perfetto.protos.TraceConfig.IncidentReportConfig'
- prune 'perfetto.protos.ProcessStatsConfig.Quirks'
-
- sourcePath {
- srcDir 'src/main/proto'
- }
-}
-
dependencies {
api(libs.junit)
api(libs.kotlinStdlib)
@@ -77,7 +52,6 @@
implementation("androidx.tracing:tracing-ktx:1.0.0")
implementation(libs.testCore)
implementation(libs.testUiautomator)
- implementation(libs.wireRuntime)
androidTestImplementation(project(":internal-testutils-ktx"))
androidTestImplementation(project(":activity:activity-ktx"))
diff --git a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/FileLinkingRule.kt b/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/FileLinkingRule.kt
index 8214ab4..bfe4fb6 100644
--- a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/FileLinkingRule.kt
+++ b/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/FileLinkingRule.kt
@@ -18,8 +18,8 @@
import androidx.benchmark.InstrumentationResults
import androidx.benchmark.Outputs
-import androidx.benchmark.macro.perfetto.UiState
-import androidx.benchmark.macro.perfetto.appendUiState
+import androidx.benchmark.perfetto.UiState
+import androidx.benchmark.perfetto.appendUiState
import org.junit.rules.RuleChain
import org.junit.rules.TestRule
import org.junit.runner.Description
diff --git a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/StartupTimingMetricTest.kt b/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/StartupTimingMetricTest.kt
index c5d3ca2..cfb5e4e 100644
--- a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/StartupTimingMetricTest.kt
+++ b/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/StartupTimingMetricTest.kt
@@ -18,9 +18,9 @@
import android.content.Intent
import androidx.annotation.RequiresApi
-import androidx.benchmark.macro.perfetto.PerfettoCaptureWrapper
-import androidx.benchmark.macro.perfetto.PerfettoHelper.Companion.isAbiSupported
-import androidx.benchmark.macro.perfetto.createTempFileFromAsset
+import androidx.benchmark.Outputs
+import androidx.benchmark.perfetto.PerfettoCaptureWrapper
+import androidx.benchmark.perfetto.PerfettoHelper.Companion.isAbiSupported
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.filters.MediumTest
@@ -32,6 +32,7 @@
import org.junit.Assume.assumeTrue
import org.junit.Test
import org.junit.runner.RunWith
+import java.io.File
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertTrue
@@ -153,3 +154,15 @@
)!!
return metric.getMetrics(packageName, tracePath)
}
+
+@Suppress("SameParameterValue")
+internal fun createTempFileFromAsset(prefix: String, suffix: String): File {
+ val file = File.createTempFile(prefix, suffix, Outputs.dirUsableByAppAndShell)
+ InstrumentationRegistry
+ .getInstrumentation()
+ .context
+ .assets
+ .open(prefix + suffix)
+ .copyTo(file.outputStream())
+ return file
+}
diff --git a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/PerfettoCaptureTest.kt b/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/PerfettoCaptureTest.kt
index 083add8..13ba705 100644
--- a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/PerfettoCaptureTest.kt
+++ b/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/PerfettoCaptureTest.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 The Android Open Source Project
+ * Copyright 2021 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.
@@ -20,8 +20,9 @@
import android.os.Build
import androidx.benchmark.macro.FileLinkingRule
import androidx.benchmark.macro.Packages
-import androidx.benchmark.macro.perfetto.PerfettoHelper.Companion.LOWEST_BUNDLED_VERSION_SUPPORTED
-import androidx.benchmark.macro.perfetto.PerfettoHelper.Companion.isAbiSupported
+import androidx.benchmark.perfetto.PerfettoCapture
+import androidx.benchmark.perfetto.PerfettoHelper.Companion.LOWEST_BUNDLED_VERSION_SUPPORTED
+import androidx.benchmark.perfetto.PerfettoHelper.Companion.isAbiSupported
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.filters.SdkSuppress
@@ -40,6 +41,12 @@
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
+/**
+ * Tests for PerfettoCapture
+ *
+ * Note: this test is defined in benchmark-macro instead of benchmark-common so that it can
+ * validate trace contents with PerfettoTraceProcessor
+ */
@SdkSuppress(minSdkVersion = 28) // Lowering blocked by b/131359446
@RunWith(AndroidJUnit4::class)
class PerfettoCaptureTest {
diff --git a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/PerfettoTraceProcessorTest.kt b/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/PerfettoTraceProcessorTest.kt
index f42d72cb..c224a52 100644
--- a/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/PerfettoTraceProcessorTest.kt
+++ b/benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/perfetto/PerfettoTraceProcessorTest.kt
@@ -17,7 +17,8 @@
package androidx.benchmark.macro.perfetto
import androidx.benchmark.Shell
-import androidx.benchmark.macro.perfetto.PerfettoHelper.Companion.isAbiSupported
+import androidx.benchmark.macro.createTempFileFromAsset
+import androidx.benchmark.perfetto.PerfettoHelper.Companion.isAbiSupported
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SdkSuppress
import androidx.test.filters.SmallTest
@@ -120,4 +121,4 @@
assets.toSet().containsAll(entries)
)
}
-}
+}
\ No newline at end of file
diff --git a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/CompilationMode.kt b/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/CompilationMode.kt
index d7dd831..a97ae5f 100644
--- a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/CompilationMode.kt
+++ b/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/CompilationMode.kt
@@ -19,6 +19,7 @@
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.annotation.RestrictTo
+import androidx.benchmark.DeviceInfo
import androidx.benchmark.Shell
import androidx.benchmark.macro.CompilationMode.SpeedProfile
import androidx.profileinstaller.ProfileInstallReceiver
diff --git a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/Macrobenchmark.kt b/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/Macrobenchmark.kt
index b4fd16c..5657ac5 100644
--- a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/Macrobenchmark.kt
+++ b/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/Macrobenchmark.kt
@@ -24,11 +24,17 @@
import androidx.annotation.RestrictTo
import androidx.benchmark.Arguments
import androidx.benchmark.BenchmarkResult
+import androidx.benchmark.ConfigurationError
+import androidx.benchmark.DeviceInfo
import androidx.benchmark.InstrumentationResults
import androidx.benchmark.ResultWriter
-import androidx.benchmark.macro.perfetto.PerfettoCaptureWrapper
-import androidx.benchmark.macro.perfetto.UiState
-import androidx.benchmark.macro.perfetto.appendUiState
+import androidx.benchmark.UserspaceTracing
+import androidx.benchmark.checkAndGetSuppressionState
+import androidx.benchmark.conditionalError
+import androidx.benchmark.perfetto.PerfettoCaptureWrapper
+import androidx.benchmark.perfetto.UiState
+import androidx.benchmark.perfetto.appendUiState
+import androidx.benchmark.userspaceTrace
import androidx.test.platform.app.InstrumentationRegistry
import java.io.File
diff --git a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoTraceProcessor.kt b/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoTraceProcessor.kt
index 281155e..6c74086 100644
--- a/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoTraceProcessor.kt
+++ b/benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/perfetto/PerfettoTraceProcessor.kt
@@ -20,7 +20,8 @@
import androidx.annotation.RequiresApi
import androidx.benchmark.Outputs
import androidx.benchmark.Shell
-import androidx.benchmark.macro.userspaceTrace
+import androidx.benchmark.perfetto.PerfettoHelper
+import androidx.benchmark.userspaceTrace
import org.jetbrains.annotations.TestOnly
import java.io.File
diff --git a/benchmark/benchmark/build.gradle b/benchmark/benchmark/build.gradle
index 09799ac..a69a0a3 100644
--- a/benchmark/benchmark/build.gradle
+++ b/benchmark/benchmark/build.gradle
@@ -21,16 +21,8 @@
id("androidx.benchmark")
}
-android {
- defaultConfig {
- // 18 needed for UI automator dependency, via benchmark-macro-junit4
- minSdkVersion 18
- }
-}
-
dependencies {
androidTestImplementation(project(":benchmark:benchmark-junit4"))
- androidTestImplementation(project(":benchmark:benchmark-macro-junit4"))
androidTestImplementation(project(":tracing:tracing-ktx"))
androidTestImplementation(libs.testRunner)
androidTestImplementation(libs.testRules)
diff --git a/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/PerfettoOverheadBenchmark.kt b/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/PerfettoOverheadBenchmark.kt
index 0b09e96..f2bfd74 100644
--- a/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/PerfettoOverheadBenchmark.kt
+++ b/benchmark/benchmark/src/androidTest/java/androidx/benchmark/benchmark/PerfettoOverheadBenchmark.kt
@@ -17,8 +17,8 @@
package androidx.benchmark.benchmark
import androidx.benchmark.junit4.BenchmarkRule
+import androidx.benchmark.junit4.PerfettoRule
import androidx.benchmark.junit4.measureRepeated
-import androidx.benchmark.macro.junit4.PerfettoRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.tracing.Trace
diff --git a/buildSrc/private/src/main/kotlin/androidx/build/uptodatedness/TaskUpToDateValidator.kt b/buildSrc/private/src/main/kotlin/androidx/build/uptodatedness/TaskUpToDateValidator.kt
index 5bfa736..7ead4b5 100644
--- a/buildSrc/private/src/main/kotlin/androidx/build/uptodatedness/TaskUpToDateValidator.kt
+++ b/buildSrc/private/src/main/kotlin/androidx/build/uptodatedness/TaskUpToDateValidator.kt
@@ -157,18 +157,18 @@
"validateProperties",
"tasks",
- ":benchmark:benchmark-macro:generateReleaseProtos",
- ":benchmark:benchmark-macro:generateDebugProtos",
- ":benchmark:benchmark-macro:compileReleaseKotlin",
- ":benchmark:benchmark-macro:compileDebugKotlin",
- ":benchmark:benchmark-macro:compileReleaseJavaWithJavac",
- ":benchmark:benchmark-macro:compileDebugJavaWithJavac",
- ":benchmark:benchmark-macro:extractReleaseAnnotations",
- ":benchmark:benchmark-macro:extractDebugAnnotations",
- ":benchmark:benchmark-macro:generateApi",
- ":benchmark:benchmark-macro:runErrorProne",
- ":benchmark:benchmark-macro:lintAnalyzeDebug",
- ":benchmark:benchmark-macro:lintDebug",
+ ":benchmark:benchmark-common:generateReleaseProtos",
+ ":benchmark:benchmark-common:generateDebugProtos",
+ ":benchmark:benchmark-common:compileReleaseKotlin",
+ ":benchmark:benchmark-common:compileDebugKotlin",
+ ":benchmark:benchmark-common:compileReleaseJavaWithJavac",
+ ":benchmark:benchmark-common:compileDebugJavaWithJavac",
+ ":benchmark:benchmark-common:extractReleaseAnnotations",
+ ":benchmark:benchmark-common:extractDebugAnnotations",
+ ":benchmark:benchmark-common:generateApi",
+ ":benchmark:benchmark-common:runErrorProne",
+ ":benchmark:benchmark-common:lintAnalyzeDebug",
+ ":benchmark:benchmark-common:lintDebug",
// More information about the fact that these dokka tasks rerun can be found at b/167569304
"dokkaKotlinDocs",
diff --git a/compose/ui/ui-graphics/benchmark/build.gradle b/compose/ui/ui-graphics/benchmark/build.gradle
index 9670e0f..90bdbca 100644
--- a/compose/ui/ui-graphics/benchmark/build.gradle
+++ b/compose/ui/ui-graphics/benchmark/build.gradle
@@ -32,6 +32,5 @@
implementation(libs.kotlinStdlib)
androidTestImplementation project(":benchmark:benchmark-junit4")
- androidTestImplementation project(":benchmark:benchmark-macro-junit4")
androidTestImplementation(libs.testRules)
}
diff --git a/compose/ui/ui-graphics/benchmark/src/androidTest/java/androidx/compose/ui/graphics/benchmark/VectorBenchmarkWithTracing.kt b/compose/ui/ui-graphics/benchmark/src/androidTest/java/androidx/compose/ui/graphics/benchmark/VectorBenchmarkWithTracing.kt
index d4e4318..33af974 100644
--- a/compose/ui/ui-graphics/benchmark/src/androidTest/java/androidx/compose/ui/graphics/benchmark/VectorBenchmarkWithTracing.kt
+++ b/compose/ui/ui-graphics/benchmark/src/androidTest/java/androidx/compose/ui/graphics/benchmark/VectorBenchmarkWithTracing.kt
@@ -16,7 +16,7 @@
package androidx.compose.ui.graphics.benchmark
-import androidx.benchmark.macro.junit4.PerfettoRule
+import androidx.benchmark.junit4.PerfettoRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import org.junit.Rule
diff --git a/development/build_log_simplifier/messages.ignore b/development/build_log_simplifier/messages.ignore
index f2684a0..af2600d 100644
--- a/development/build_log_simplifier/messages.ignore
+++ b/development/build_log_simplifier/messages.ignore
@@ -540,7 +540,7 @@
# https://youtrack.jetbrains.com/issue/KT-30589
WARNING: Illegal reflective access by org\.jetbrains\.kotlin\.kapt3\.base\.javac\.KaptJavaFileManager .* to method com\.sun\.tools\.javac\.file\.BaseFileManager\.handleOption\(com\.sun\.tools\.javac\.main\.Option,java\.lang\.String\)
# > Task :benchmark:benchmark-macro:compileReleaseKotlin
-Execution optimizations have been disabled for task ':benchmark:benchmark\-macro:.*' to ensure correctness due to the following reasons:
+Execution optimizations have been disabled for task ':benchmark:benchmark\-common:.*' to ensure correctness due to the following reasons:
\- Gradle detected a problem with the following location: '\$OUT_DIR/androidx/benchmark/benchmark\-macro/build/generated/source/wire'\. Reason: Task ':benchmark:benchmark\-macro:.*' uses this output of task ':benchmark:benchmark\-macro:.*' without declaring an explicit or implicit dependency\. This can lead to incorrect results being produced, depending on what order the tasks are executed\. Please refer to https://docs\.gradle\.org/[0-9]+\.[0-9]+/userguide/validation_problems\.html\#implicit_dependency for more details about this problem\.
# > Task :profileinstaller:profileinstaller:processDebugUnitTestManifest
Scanning .+: \.*
@@ -603,5 +603,5 @@
WARNING\:The option setting \'android\.dependencyResolutionAtConfigurationTime\.disallow\=true\' is experimental\.
# b/195025261
Unable to detect AGP versions for included builds\. All projects in the build should use the same AGP version\. Class name for the included build .*
-\- Gradle detected a problem with the following location: '\$OUT_DIR/androidx/benchmark/benchmark-macro/build/generated/source/wire'\. Reason: Task ':benchmark:benchmark-macro:.*' uses this output of task ':benchmark:benchmark-macro:generate(Debug|Release)Protos' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to .*
+\- Gradle detected a problem with the following location: '\$OUT_DIR/androidx/benchmark/benchmark-common/build/generated/source/wire'\. Reason: Task ':benchmark:benchmark-common:.*' uses this output of task ':benchmark:benchmark-common:generate(Debug|Release)Protos' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to .*
To honour the JVM settings for this build a single\-use Daemon process will be forked.*
diff --git a/settings.gradle b/settings.gradle
index d37e963..3e7186d 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -725,7 +725,7 @@
includeProject(":internal-testutils-appcompat", "testutils/testutils-appcompat", [BuildType.MAIN])
includeProject(":internal-testutils-espresso", "testutils/testutils-espresso", [BuildType.MAIN])
includeProject(":internal-testutils-truth", "testutils/testutils-truth", [BuildType.MAIN, BuildType.FLAN])
-includeProject(":internal-testutils-ktx", "testutils/testutils-ktx", [BuildType.MAIN, BuildType.COMPOSE])
+includeProject(":internal-testutils-ktx", "testutils/testutils-ktx")
includeProject(":internal-testutils-macrobenchmark", "testutils/testutils-macrobenchmark", [BuildType.MAIN, BuildType.COMPOSE])
includeProject(":internal-testutils-navigation", "testutils/testutils-navigation", [BuildType.MAIN, BuildType.COMPOSE, BuildType.FLAN])
includeProject(":internal-testutils-paging", "testutils/testutils-paging", [BuildType.MAIN, BuildType.COMPOSE])