Improve conversation open benchmark test.
This commit is contained in:
parent
7e909f2bee
commit
aee0b5268f
7 changed files with 38 additions and 9 deletions
|
@ -148,6 +148,7 @@ object TestMessages {
|
||||||
1024,
|
1024,
|
||||||
1024,
|
1024,
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
|
Optional.empty(),
|
||||||
Optional.of("/not-there.jpg"),
|
Optional.of("/not-there.jpg"),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
@ -169,6 +170,7 @@ object TestMessages {
|
||||||
1024,
|
1024,
|
||||||
1024,
|
1024,
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
|
Optional.empty(),
|
||||||
Optional.of("/not-there.aac"),
|
Optional.of("/not-there.aac"),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -65,7 +65,7 @@ object TestUsers {
|
||||||
).blockingGet()
|
).blockingGet()
|
||||||
ServiceResponseProcessor.DefaultProcessor(response).resultOrThrow
|
ServiceResponseProcessor.DefaultProcessor(response).resultOrThrow
|
||||||
|
|
||||||
SignalStore.kbsValues().optOut()
|
SignalStore.svr().optOut()
|
||||||
RegistrationUtil.maybeMarkRegistrationComplete()
|
RegistrationUtil.maybeMarkRegistrationComplete()
|
||||||
SignalDatabase.recipients.setProfileName(Recipient.self().id, ProfileName.fromParts("Tester", "McTesterson"))
|
SignalDatabase.recipients.setProfileName(Recipient.self().id, ProfileName.fromParts("Tester", "McTesterson"))
|
||||||
|
|
||||||
|
|
|
@ -292,7 +292,6 @@ public class ConversationFragment extends LoggingFragment implements Multiselect
|
||||||
this.locale = Locale.getDefault();
|
this.locale = Locale.getDefault();
|
||||||
startupStopwatch = new Stopwatch("conversation-open");
|
startupStopwatch = new Stopwatch("conversation-open");
|
||||||
SignalLocalMetrics.ConversationOpen.start();
|
SignalLocalMetrics.ConversationOpen.start();
|
||||||
SignalTrace.beginSection("ConversationOpen");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -405,7 +404,6 @@ public class ConversationFragment extends LoggingFragment implements Multiselect
|
||||||
startupStopwatch.stop(TAG);
|
startupStopwatch.stop(TAG);
|
||||||
SignalLocalMetrics.ConversationOpen.onRenderFinished();
|
SignalLocalMetrics.ConversationOpen.onRenderFinished();
|
||||||
listener.onFirstRender();
|
listener.onFirstRender();
|
||||||
SignalTrace.endSection();
|
|
||||||
return Unit.INSTANCE;
|
return Unit.INSTANCE;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,29 +82,41 @@ public final class SignalLocalMetrics {
|
||||||
private static String id;
|
private static String id;
|
||||||
|
|
||||||
public static void start() {
|
public static void start() {
|
||||||
|
SignalTrace.beginSection("6-ConversationOpen");
|
||||||
id = NAME + "-" + System.currentTimeMillis();
|
id = NAME + "-" + System.currentTimeMillis();
|
||||||
LocalMetrics.getInstance().start(id, NAME);
|
LocalMetrics.getInstance().start(id, NAME);
|
||||||
|
SignalTrace.beginSection("1-ConversationOpen-ViewModel-Init");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onMetadataLoadStarted() {
|
public static void onMetadataLoadStarted() {
|
||||||
|
SignalTrace.endSection();
|
||||||
LocalMetrics.getInstance().split(id, SPLIT_VIEWMODEL_INIT);
|
LocalMetrics.getInstance().split(id, SPLIT_VIEWMODEL_INIT);
|
||||||
|
SignalTrace.beginSection("2-ConversationOpen-Metadata-Loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onMetadataLoaded() {
|
public static void onMetadataLoaded() {
|
||||||
|
SignalTrace.endSection();
|
||||||
LocalMetrics.getInstance().split(id, SPLIT_METADATA_LOADED);
|
LocalMetrics.getInstance().split(id, SPLIT_METADATA_LOADED);
|
||||||
|
SignalTrace.beginSection("3-ConversationOpen-Data-Loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onDataLoaded() {
|
public static void onDataLoaded() {
|
||||||
|
SignalTrace.endSection();
|
||||||
LocalMetrics.getInstance().split(id, SPLIT_DATA_LOADED);
|
LocalMetrics.getInstance().split(id, SPLIT_DATA_LOADED);
|
||||||
|
SignalTrace.beginSection("4-ConversationOpen-Data-Posted");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onDataPostedToMain() {
|
public static void onDataPostedToMain() {
|
||||||
|
SignalTrace.endSection();
|
||||||
LocalMetrics.getInstance().split(id, SPLIT_DATA_POSTED);
|
LocalMetrics.getInstance().split(id, SPLIT_DATA_POSTED);
|
||||||
|
SignalTrace.beginSection("5-ConversationOpen-Render");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onRenderFinished() {
|
public static void onRenderFinished() {
|
||||||
|
SignalTrace.endSection();
|
||||||
LocalMetrics.getInstance().split(id, SPLIT_RENDER);
|
LocalMetrics.getInstance().split(id, SPLIT_RENDER);
|
||||||
LocalMetrics.getInstance().end(id);
|
LocalMetrics.getInstance().end(id);
|
||||||
|
SignalTrace.endSection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
package org.thoughtcrime.securesms.util
|
package org.thoughtcrime.securesms.util
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.BuildConfig
|
import org.thoughtcrime.securesms.BuildConfig
|
||||||
|
import java.util.concurrent.Executors
|
||||||
import androidx.tracing.Trace as AndroidTrace
|
import androidx.tracing.Trace as AndroidTrace
|
||||||
|
|
||||||
object SignalTrace {
|
object SignalTrace {
|
||||||
|
|
||||||
|
private val executor by lazy(LazyThreadSafetyMode.NONE) {
|
||||||
|
Executors.newSingleThreadExecutor()
|
||||||
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun beginSection(methodName: String) {
|
fun beginSection(methodName: String) {
|
||||||
if (!BuildConfig.TRACING_ENABLED) {
|
if (!BuildConfig.TRACING_ENABLED) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
AndroidTrace.beginSection(methodName)
|
executor.execute { AndroidTrace.beginSection(methodName) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@ -17,6 +23,6 @@ object SignalTrace {
|
||||||
if (!BuildConfig.TRACING_ENABLED) {
|
if (!BuildConfig.TRACING_ENABLED) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
AndroidTrace.endSection()
|
executor.execute { AndroidTrace.endSection() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
package org.thoughtcrime.benchmark
|
package org.thoughtcrime.benchmark
|
||||||
|
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.Intent
|
|
||||||
import androidx.benchmark.macro.ExperimentalBaselineProfilesApi
|
import androidx.benchmark.macro.ExperimentalBaselineProfilesApi
|
||||||
import androidx.benchmark.macro.junit4.BaselineProfileRule
|
import androidx.benchmark.macro.junit4.BaselineProfileRule
|
||||||
import androidx.test.uiautomator.By
|
import androidx.test.uiautomator.By
|
||||||
|
@ -18,6 +16,7 @@ import org.junit.Test
|
||||||
* - start the app
|
* - start the app
|
||||||
* - open a conversation
|
* - open a conversation
|
||||||
*/
|
*/
|
||||||
|
@OptIn(ExperimentalBaselineProfilesApi::class)
|
||||||
class BaselineProfileGenerator {
|
class BaselineProfileGenerator {
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val baselineProfileRule = BaselineProfileRule()
|
val baselineProfileRule = BaselineProfileRule()
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.thoughtcrime.benchmark
|
package org.thoughtcrime.benchmark
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
|
import android.os.Build
|
||||||
import androidx.benchmark.macro.CompilationMode
|
import androidx.benchmark.macro.CompilationMode
|
||||||
import androidx.benchmark.macro.ExperimentalMetricApi
|
import androidx.benchmark.macro.ExperimentalMetricApi
|
||||||
import androidx.benchmark.macro.TraceSectionMetric
|
import androidx.benchmark.macro.TraceSectionMetric
|
||||||
|
@ -22,7 +24,14 @@ class ConversationBenchmarks {
|
||||||
var setup = false
|
var setup = false
|
||||||
benchmarkRule.measureRepeated(
|
benchmarkRule.measureRepeated(
|
||||||
packageName = "org.thoughtcrime.securesms",
|
packageName = "org.thoughtcrime.securesms",
|
||||||
metrics = listOf(TraceSectionMetric("ConversationOpen")),
|
metrics = listOf(
|
||||||
|
TraceSectionMetric("6-ConversationOpen"),
|
||||||
|
TraceSectionMetric("1-ConversationOpen-ViewModel-Init"),
|
||||||
|
TraceSectionMetric("2-ConversationOpen-Metadata-Loaded"),
|
||||||
|
TraceSectionMetric("3-ConversationOpen-Data-Loaded"),
|
||||||
|
TraceSectionMetric("4-ConversationOpen-Data-Posted"),
|
||||||
|
TraceSectionMetric("5-ConversationOpen-Render"),
|
||||||
|
),
|
||||||
iterations = 10,
|
iterations = 10,
|
||||||
compilationMode = CompilationMode.Partial(),
|
compilationMode = CompilationMode.Partial(),
|
||||||
setupBlock = {
|
setupBlock = {
|
||||||
|
@ -31,10 +40,13 @@ class ConversationBenchmarks {
|
||||||
setup = true
|
setup = true
|
||||||
}
|
}
|
||||||
killProcess()
|
killProcess()
|
||||||
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
|
device.executeShellCommand("pm grant $packageName ${Manifest.permission.POST_NOTIFICATIONS}")
|
||||||
|
}
|
||||||
startActivityAndWait()
|
startActivityAndWait()
|
||||||
device.waitForIdle()
|
device.waitForIdle()
|
||||||
}) {
|
}) {
|
||||||
device.findObject(By.textContains("Buddy")).click();
|
device.findObject(By.textContains("Buddy")).click()
|
||||||
device.wait(Until.hasObject(By.textContains("Signal message")), 10_000L)
|
device.wait(Until.hasObject(By.textContains("Signal message")), 10_000L)
|
||||||
device.wait(Until.hasObject(By.textContains("Test")), 5_000L)
|
device.wait(Until.hasObject(By.textContains("Test")), 5_000L)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue