mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-23 11:15:44 +00:00
Add benchmark for conversation open.
This commit is contained in:
@@ -23,22 +23,20 @@ class BaselineProfileGenerator {
|
||||
val baselineProfileRule = BaselineProfileRule()
|
||||
|
||||
@Test
|
||||
fun startup() = baselineProfileRule.collectBaselineProfile(
|
||||
packageName = "org.thoughtcrime.securesms",
|
||||
profileBlock = {
|
||||
if (iteration == 0) {
|
||||
val setupIntent = Intent().apply {
|
||||
component = ComponentName("org.thoughtcrime.securesms", "org.signal.benchmark.BenchmarkSetupActivity")
|
||||
fun startup() {
|
||||
var setup = false
|
||||
baselineProfileRule.collectBaselineProfile(
|
||||
packageName = "org.thoughtcrime.securesms",
|
||||
profileBlock = {
|
||||
if (!setup) {
|
||||
BenchmarkSetup.setup("cold-start", device)
|
||||
setup = true
|
||||
}
|
||||
startActivityAndWait(setupIntent)
|
||||
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)
|
||||
}
|
||||
startActivityAndWait()
|
||||
device.findObject(By.textContains("Buddy")).click();
|
||||
device.wait(
|
||||
Until.hasObject(By.clazz("$packageName.conversation.ConversationActivity")),
|
||||
10000L
|
||||
)
|
||||
device.wait(Until.hasObject(By.textContains("Test")), 10_000L)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.thoughtcrime.benchmark
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.thoughtcrime.benchmark
|
||||
|
||||
import androidx.benchmark.macro.CompilationMode
|
||||
import androidx.benchmark.macro.ExperimentalMetricApi
|
||||
import androidx.benchmark.macro.TraceSectionMetric
|
||||
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.Until
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ConversationBenchmarks {
|
||||
@get:Rule
|
||||
val benchmarkRule = MacrobenchmarkRule()
|
||||
|
||||
@OptIn(ExperimentalMetricApi::class)
|
||||
@Test
|
||||
fun simpleConversationOpen() {
|
||||
var setup = false
|
||||
benchmarkRule.measureRepeated(
|
||||
packageName = "org.thoughtcrime.securesms",
|
||||
metrics = listOf(TraceSectionMetric("ConversationOpen")),
|
||||
iterations = 10,
|
||||
compilationMode = CompilationMode.Partial(),
|
||||
setupBlock = {
|
||||
if (!setup) {
|
||||
BenchmarkSetup.setup("conversation-open", device)
|
||||
setup = true
|
||||
}
|
||||
killProcess()
|
||||
startActivityAndWait()
|
||||
device.waitForIdle()
|
||||
}) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import androidx.benchmark.macro.StartupTimingMetric
|
||||
import androidx.benchmark.macro.TraceSectionMetric
|
||||
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.Until
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -34,18 +36,9 @@ class StartupBenchmarks {
|
||||
measureStartup(5, CompilationMode.Partial())
|
||||
}
|
||||
|
||||
private val fakeDataSetupBlock: MacrobenchmarkScope.() -> Unit = {
|
||||
val setupIntent = Intent().apply {
|
||||
component = ComponentName("org.thoughtcrime.securesms", "org.signal.benchmark.BenchmarkSetupActivity")
|
||||
}
|
||||
startActivityAndWait(setupIntent)
|
||||
|
||||
killProcess()
|
||||
dropKernelPageCache()
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMetricApi::class)
|
||||
private fun measureStartup(iterations: Int, compilationMode: CompilationMode) {
|
||||
var setup = false
|
||||
benchmarkRule.measureRepeated(
|
||||
packageName = "org.thoughtcrime.securesms",
|
||||
metrics = listOf(StartupTimingMetric(), TraceSectionMetric("ConversationListDataSource#load")),
|
||||
@@ -53,8 +46,12 @@ class StartupBenchmarks {
|
||||
startupMode = StartupMode.COLD,
|
||||
compilationMode = compilationMode,
|
||||
setupBlock = {
|
||||
if (compilationMode !is CompilationMode.Partial || iteration == 0) {
|
||||
fakeDataSetupBlock()
|
||||
if (!setup) {
|
||||
BenchmarkSetup.setup("cold-start", device)
|
||||
|
||||
killProcess()
|
||||
dropKernelPageCache()
|
||||
setup = true
|
||||
}
|
||||
}
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user