Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: tools/android/customtabs_benchmark/scripts/customtabs_benchmark.py

Issue 2508933002: tools: Local tests for the speculative prefetch predictor. (Closed)
Patch Set: . Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/resource_prefetch_predictor/generate_database.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/customtabs_benchmark/scripts/customtabs_benchmark.py
diff --git a/tools/android/customtabs_benchmark/scripts/customtabs_benchmark.py b/tools/android/customtabs_benchmark/scripts/customtabs_benchmark.py
index 2cda5c09640b8c4009885eeeb60a5f85fff74628..219a1751ae27e20d225b13f43cbf7870247227de 100755
--- a/tools/android/customtabs_benchmark/scripts/customtabs_benchmark.py
+++ b/tools/android/customtabs_benchmark/scripts/customtabs_benchmark.py
@@ -6,6 +6,7 @@
"""Loops Custom Tabs tests and outputs the results into a CSV file."""
+import collections
import contextlib
import logging
import optparse
@@ -38,7 +39,7 @@ _COMMAND_LINE_PATH = '/data/local/tmp/chrome-command-line'
_TEST_APP_PACKAGE_NAME = 'org.chromium.customtabsclient.test'
# Command line arguments for Chrome.
-_CHROME_ARGS = [
+CHROME_ARGS = [
# Disable backgound network requests that may pollute WPR archive, pollute
# HTTP cache generation, and introduce noise in loading performance.
'--disable-background-networking',
@@ -67,7 +68,7 @@ def ResetChromeLocalState(device):
def RunOnce(device, url, warmup, speculation_mode, delay_to_may_launch_url,
- delay_to_launch_url, cold, chrome_args):
+ delay_to_launch_url, cold, chrome_args, reset_chrome_state):
"""Runs a test on a device once.
Args:
@@ -79,6 +80,8 @@ def RunOnce(device, url, warmup, speculation_mode, delay_to_may_launch_url,
delay_to_launch_url: (int) Delay to launchUrl() in ms.
cold: (bool) Whether the page cache should be dropped.
chrome_args: ([str]) List of arguments to pass to Chrome.
+ reset_chrome_state: (bool) Whether to reset the Chrome local state before
+ the run.
Returns:
The output line (str), like this (one line only):
@@ -110,7 +113,8 @@ def RunOnce(device, url, warmup, speculation_mode, delay_to_may_launch_url,
device.ForceStop(_CHROME_PACKAGE)
device.ForceStop(_TEST_APP_PACKAGE_NAME)
- ResetChromeLocalState(device)
+ if reset_chrome_state:
+ ResetChromeLocalState(device)
if cold:
cache_control.CacheControl(device).DropRamCaches()
@@ -127,6 +131,30 @@ def RunOnce(device, url, warmup, speculation_mode, delay_to_may_launch_url,
return match.group(1) if match is not None else None
+Result = collections.namedtuple('Result', ['warmup', 'speculation_mode',
+ 'delay_to_may_launch_url',
+ 'delay_to_launch_url',
+ 'commit', 'plt',
+ 'first_contentful_paint'])
+
+
+def ParseResult(result_line):
+ """Parses a result line, and returns it.
+
+ Args:
+ result_line: (str) A result line, as returned by RunOnce().
+
+ Returns:
+ An instance of Result.
+ """
+ tokens = result_line.strip().split(',')
+ assert len(tokens) == 8
+ intent_sent_timestamp = int(tokens[4])
+ return Result(bool(tokens[0]), tokens[1], int(tokens[2]), int(tokens[3]),
+ int(tokens[5]) - intent_sent_timestamp,
+ int(tokens[6]) - intent_sent_timestamp, int(tokens[7]))
+
+
def LoopOnDevice(device, configs, output_filename, wpr_archive_path=None,
wpr_record=None, network_condition=None, wpr_log_path=None,
once=False, should_stop=None):
@@ -157,7 +185,7 @@ def LoopOnDevice(device, configs, output_filename, wpr_archive_path=None,
config['speculation_mode'],
config['delay_to_may_launch_url'],
config['delay_to_launch_url'], config['cold'],
- chrome_args)
+ chrome_args, reset_chrome_state=True)
if result is not None:
out.write(result + '\n')
out.flush()
« no previous file with comments | « no previous file | tools/resource_prefetch_predictor/generate_database.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698