mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-15 07:28:30 +00:00
Split performance benchmark and baseline profile into separate modules.
This commit is contained in:
committed by
Greyson Parrelli
parent
3dd5ad2a8a
commit
4a39c7950f
1
baseline-profile/.gitignore
vendored
Normal file
1
baseline-profile/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
76
baseline-profile/build.gradle.kts
Normal file
76
baseline-profile/build.gradle.kts
Normal file
@@ -0,0 +1,76 @@
|
||||
plugins {
|
||||
id("com.android.test")
|
||||
alias(libs.plugins.jetbrains.kotlin.android)
|
||||
alias(benchmarkLibs.plugins.baselineprofile)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "org.signal.baselineprofile"
|
||||
compileSdk {
|
||||
version = release(36)
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.toVersion(libs.versions.javaVersion.get())
|
||||
targetCompatibility = JavaVersion.toVersion(libs.versions.javaVersion.get())
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = libs.versions.kotlinJvmTarget.get()
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 28
|
||||
targetSdk = 36
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
create("mocked") {
|
||||
matchingFallbacks += "debug"
|
||||
isDebuggable = true
|
||||
}
|
||||
}
|
||||
|
||||
targetProjectPath = ":Signal-Android"
|
||||
|
||||
flavorDimensions += listOf("distribution", "environment")
|
||||
productFlavors {
|
||||
create("play") { dimension = "distribution" }
|
||||
create("prod") { dimension = "environment" }
|
||||
}
|
||||
|
||||
testOptions {
|
||||
managedDevices {
|
||||
localDevices {
|
||||
create("api31") {
|
||||
device = "Pixel 3"
|
||||
apiLevel = 31
|
||||
systemImageSource = "aosp"
|
||||
require64Bit = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
baselineProfile {
|
||||
managedDevices += "api31"
|
||||
useConnectedDevices = false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(benchmarkLibs.androidx.test.ext.junit)
|
||||
implementation(benchmarkLibs.espresso.core)
|
||||
implementation(benchmarkLibs.uiautomator)
|
||||
implementation(benchmarkLibs.androidx.benchmark.macro)
|
||||
}
|
||||
|
||||
androidComponents {
|
||||
beforeVariants(selector().all()) {
|
||||
if (it.flavorName != "playProd" && it.buildType != "mocked") {
|
||||
it.enable = false
|
||||
}
|
||||
}
|
||||
}
|
||||
1
baseline-profile/src/main/AndroidManifest.xml
Normal file
1
baseline-profile/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
||||
<manifest />
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.signal.baselineprofile
|
||||
|
||||
import androidx.benchmark.macro.junit4.BaselineProfileRule
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.Until
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
/**
|
||||
* WARNING! THIS WILL WIPE YOUR SIGNAL INSTALL
|
||||
*
|
||||
* Test that generates a Baseline profile from a user journey. Our journey is:
|
||||
* - start the app
|
||||
* - open a conversation
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class BaselineProfileGenerator {
|
||||
|
||||
@get:Rule
|
||||
val baselineProfileRule = BaselineProfileRule()
|
||||
|
||||
@Test
|
||||
fun startup() {
|
||||
var setup = false
|
||||
baselineProfileRule.collect(
|
||||
packageName = "org.thoughtcrime.securesms",
|
||||
includeInStartupProfile = true,
|
||||
profileBlock = {
|
||||
if (!setup) {
|
||||
BenchmarkSetup.setup("cold-start", device)
|
||||
setup = true
|
||||
}
|
||||
|
||||
pressHome()
|
||||
startActivityAndWait()
|
||||
device.findObject(By.textContains("Buddy")).click()
|
||||
device.wait(Until.hasObject(By.textContains("Signal message")), 10_000L)
|
||||
device.wait(Until.hasObject(By.textContains("Test")), 5_000L)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.signal.baselineprofile
|
||||
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import androidx.test.uiautomator.Until
|
||||
|
||||
object BenchmarkSetup {
|
||||
fun setup(type: String, device: UiDevice) {
|
||||
device.executeShellCommand("am start -W -n org.thoughtcrime.securesms/org.signal.benchmark.BenchmarkSetupActivity --es setup-type $type")
|
||||
device.wait(Until.hasObject(By.textContains("done")), 25_000L)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user