Commit 36461533 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

[WebLayer] Add benchmark to measure early startup time

This metric measures code loading time for WebLayer, and reuses the
logic from the WebView startup test.

Bug: 1137468
Change-Id: I9045bb47b119470881c1500650a9ed9127295afe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2466482
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816418}
parent 00853f25
......@@ -3,6 +3,7 @@ See the following link for directions for making changes to this data:,https://b
Googlers can view additional information about internal perf infrastructure at,https://goto.google.com/chrome-benchmarking-sheet
Benchmark name,Individual owners,Component,Documentation,Tags
UNSCHEDULED_blink_perf.service_worker,"shimazu@chromium.org, falken@chromium.org, ting.shao@intel.com",Blink>ServiceWorker,https://bit.ly/blink-perf-benchmarks,
UNSCHEDULED_system_health.weblayer_startup,"cduvall@chromium.org, weblayer-team@chromium.org",Internals>WebLayer,https://bit.ly/36XBtpn,2016
angle_perftests,"jmadill@chromium.org, chrome-gpu-perf-owners@chromium.org",Internals>GPU>ANGLE,,
base_perftests,"skyostil@chromium.org, gab@chromium.org",Internals>SequenceManager,https://chromium.googlesource.com/chromium/src/+/HEAD/base/README.md#performance-testing,
blink_perf.accessibility,dmazzoni@chromium.org,Blink>Accessibility,https://bit.ly/blink-perf-benchmarks,all
......
......@@ -246,3 +246,30 @@ class WebviewStartupSystemHealthBenchmark(perf_benchmark.PerfBenchmark):
@classmethod
def Name(cls):
return 'system_health.webview_startup'
@benchmark.Info(emails=['cduvall@chromium.org', 'weblayer-team@chromium.org'],
component='Internals>WebLayer',
documentation_url='https://bit.ly/36XBtpn')
class WebLayerStartupSystemHealthBenchmark(WebviewStartupSystemHealthBenchmark):
"""WebLayer startup time benchmark
Benchmark that measures how long WebLayer takes to start up
and load a blank page.
"""
# TODO(rmhasan): Remove the SUPPORTED_PLATFORMS lists.
# SUPPORTED_PLATFORMS is deprecated, please put system specifier tags
# from expectations.config in SUPPORTED_PLATFORM_TAGS.
# TODO(crbug.com/1137468): Add WEBLAYER to telemetry platforms.
SUPPORTED_PLATFORM_TAGS = [platforms.MOBILE]
SUPPORTED_PLATFORMS = [story.expectations.ALL_MOBILE]
def CreateCoreTimelineBasedMeasurementOptions(self):
options = super(WebLayerStartupSystemHealthBenchmark,
self).CreateCoreTimelineBasedMeasurementOptions()
options.config.atrace_config.app_name = 'org.chromium.weblayer.shell'
return options
@classmethod
def Name(cls):
return 'UNSCHEDULED_system_health.weblayer_startup'
......@@ -28,12 +28,17 @@ class TestSystemHealthBenchmarks(unittest.TestCase):
def testNamePrefix(self):
for b in _GetAllSystemHealthBenchmarks():
# TODO(crbug.com/1137468): Right now this has the UNSCHEDULED_ prefix.
if b is system_health_benchmark.WebLayerStartupSystemHealthBenchmark:
continue
self.assertTrue(
b.Name().startswith('system_health.'),
'%r must have name starting with "system_health." prefix' % b)
def testSystemHealthStorySetIsUsed(self):
for b in _GetAllSystemHealthBenchmarks():
if b is system_health_benchmark.WebLayerStartupSystemHealthBenchmark:
continue
if b is system_health_benchmark.WebviewStartupSystemHealthBenchmark:
continue
self.assertIsInstance(
......
......@@ -6,6 +6,7 @@ package org.chromium.weblayer.shell;
import android.net.Uri;
import android.os.Bundle;
import android.os.Trace;
import android.text.InputType;
import android.view.View;
import android.view.ViewGroup;
......@@ -21,6 +22,8 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import org.chromium.weblayer.Browser;
import org.chromium.weblayer.Navigation;
import org.chromium.weblayer.NavigationCallback;
import org.chromium.weblayer.Profile;
import org.chromium.weblayer.Tab;
import org.chromium.weblayer.TabCallback;
......@@ -37,6 +40,12 @@ import java.util.List;
public class TelemetryActivity extends FragmentActivity {
private static final String KEY_MAIN_VIEW_ID = "mainViewId";
// The trace tag names are the same as WebView's telemetry activity so the perf metric logic can
// be shared between them.
private static final String START_UP_TRACE_TAG = "WebViewStartupInterval";
private static final String LOAD_URL_TRACE_TAG = "WebViewBlankUrlLoadInterval";
private static final String DUMMY_TRACE_TAG = "WebViewDummyInterval";
private Profile mProfile;
private Fragment mFragment;
private Browser mBrowser;
......@@ -77,6 +86,14 @@ public class TelemetryActivity extends FragmentActivity {
mTopContentsContainer.addView(
mUrlView, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0));
Trace.beginSection(START_UP_TRACE_TAG);
// TODO(aluo): Use async tracing to avoid having to do this
// dummyTraceTag is needed here to prevent code in Android intended to
// end activityStart from ending loadUrlTraceTag prematurely,
// see crbug/919221
Trace.beginSection(DUMMY_TRACE_TAG);
// If activity is re-created during process restart, FragmentManager attaches
// BrowserFragment immediately, resulting in synchronous init. By the time this line
// executes, the synchronous init has already happened, so WebLayer#createAsync will
......@@ -102,6 +119,11 @@ public class TelemetryActivity extends FragmentActivity {
}
private void onWebLayerReady(WebLayer webLayer) {
// Ends START_UP_TRACE_TAG
Trace.endSection();
// Ends activityStart
Trace.endSection();
if (mBrowser != null || isFinishing() || isDestroyed()) return;
webLayer.setRemoteDebuggingEnabled(true);
......@@ -113,6 +135,14 @@ public class TelemetryActivity extends FragmentActivity {
mBrowser.setTopView(mTopContentsContainer);
setTab(mBrowser.getActiveTab());
Trace.beginSection(LOAD_URL_TRACE_TAG);
mTab.getNavigationController().registerNavigationCallback(new NavigationCallback() {
@Override
public void onNavigationCompleted(Navigation navigation) {
// Ends LOAD_URL_TRACE_TAG
Trace.endSection();
}
});
if (getIntent() != null) {
mTab.getNavigationController().navigate(Uri.parse(getIntent().getDataString()));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment