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

Side by Side Diff: tools/resource_prefetch_predictor/prefetch_predictor_common.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 unified diff | Download patch
« no previous file with comments | « tools/resource_prefetch_predictor/prefetch_benchmark.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Common utils for the speculative resource prefetch evaluation."""
6
7 import os
8 import sys
9
10 _SRC_PATH = os.path.abspath(os.path.join(
11 os.path.dirname(__file__), os.pardir, os.pardir))
12
13 sys.path.append(os.path.join(_SRC_PATH, 'third_party', 'catapult', 'devil'))
14 from devil.android import device_utils
15
16 sys.path.append(os.path.join(_SRC_PATH, 'tools', 'android', 'loading'))
17 import controller
18 import device_setup
19 from options import OPTIONS
20
21
22 def FindDevice(device_id):
23 """Returns a device matching |device_id| or the first one if None, or None."""
24 devices = device_utils.DeviceUtils.HealthyDevices()
25 if device_id is None:
26 return devices[0]
27 return device_setup.GetDeviceFromSerial(device_id)
28
29
30 def Setup(device, additional_flags=None):
31 """Sets up a |device| and returns an instance of RemoteChromeController.
32
33 Args:
34 device: (Device) As returned by FindDevice().
35 additional_flags: ([str] or None) Chrome flags to add.
36 """
37 if not device.HasRoot():
38 device.EnableRoot()
39 chrome_controller = controller.RemoteChromeController(device)
40 device.ForceStop(OPTIONS.ChromePackage().package)
41 if additional_flags is not None:
42 chrome_controller.AddChromeArguments(additional_flags)
43 chrome_controller.ResetBrowserState()
44 return chrome_controller
45
46
47 def DatabaseDevicePath():
48 return ('/data/user/0/%s/app_chrome/Default/Network Action Predictor' %
49 OPTIONS.ChromePackage().package)
OLDNEW
« no previous file with comments | « tools/resource_prefetch_predictor/prefetch_benchmark.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698