There are two distinct pieces that often get called the same thing: Telemetry-based scrolling / performance benchmarks -- A thin Python wrapper around Telemetry that uses it to open Chrome with a special flag ( --enable-gpu-benchmarking), loads a bunch of web pages in succession, and for each of those web pages executes some JS that calls private window.chrome APIs that are only exposed when --enabled-gpu-benchmarking is on. These APIs then return rendering stats (how much time we spent painting, how many composites have occurred over the lifetime of the page, etc) to JS, and then Telemetry tunnels them out to the scrolling benchmark (i.e. back in Python land). The scrolling benchmark then saves them or prints to console. Read more about these telemetry benchmarks.Great overview of Telemetry - deck from Chrome Testing Summit. How to write benchmarks in telemetry: Benchmarks == Measurements + Page Set Goals
Should my test use Telemetry?Well, it depends on what you are trying to test or measure. Telemetry is designed for performance tests that:
Useful LinksUsing TelemetrySetting Up Telemetry (instructions per platform)Windows/Mac/Linux: You need a Chrome binary (any will do, including standard official release builds or Canaries), Python, and a Chrome source checkout (you just need the checkout, you don't have to build it! - get the code). In order to use cached sites (webpage replay), remember to download src-internal (http://go/read-src-internal/). Android: You need ADB, an Android phone with a recent version of Chrome for Android set up for remote debugging (no root required!), and a Chrome checkout set up to build for Android. Follow these steps to get up and running:
Now if you plug your phone into your desktop and run: tools/perf/run_multipage_benchmarks --browser=listyou should see Chrome for Android options. Once you see that, you're all set, and can continue with "Running a Benchmark" below. Chrome OS:
Running a BenchmarkTo run a benchmark, use the run_multipage_benchmarks script. For example, to run the scrolling benchmark over the top 25 pages:tools/perf/run_multipage_benchmarks --browser=canary smoothness_measurement tools/perf/page_sets/top_25.jsonLets break down this command a bit:
By default, telemetry starts the browser with the default arguments in a completely clean profile. To change the arguments that chrome is launched with, pass --extra-browse-args="--arg1 --arg2" For example, to run a benchmark in forced, threaded compositing mode:tools/perf/run_multipage_benchmarks --browser=system smoothness_benchmark tools/perf/page_sets/top_25.json --extra-browser-args="--force-compositing-mode --enable-threaded-compositing"ChromeOSRun telemetry with --browser=cros-chrome and --remote=<ip address> AndroidWhile running a benchmark, do not disconnect your device. This can leave your Chrome for Android unable to reach the internet. If this happens, run the appropriate command below (for Chrome or content shell): /data/local/chrome-command-line (no tmp/)/data/local/tmp/content-shell-command-lineRecording a Page SetEach page_set should have a recorded web page archive associated with it. This allows the benchmark to be run stably over the same web content. To record a new archive: tools/perf/record_wpr --browser=(release|system) page_setFor example:tools/perf/record_wpr --browser=system tools/perf/page_sets/top_25.jsonTo record only some pages in the page set, use --page-filter, for example: tools/perf/record_wpr --browser=system --page-filter=wikipedia tools/perf/page_sets/top_25.jsonUseful/Common CommandsList of benchmarks and page sets: tools/perf/run_multipage_benchmarks --browser=system List of valid browser options: tools/perf/run_multipage_benchmarks --browser=list Modifying TelemetryCode and ArchitectureThe framework lives in src/tools/telemetry and the benchmarks in src/tools/perf.On top of Telemetry, there are two fundamental concepts: -- benchmark: a python script that instrument and collect data, these live in src/tools/perf/perf_tools -- page set: a collection of pages (either links for live sites, or a WebPageReplay archive) against which we run the benchmark.
To customize the browser command line, implement CustomizeBrowserOptions(). For example:def CustomizeBrowserOptions(self, options): options.AppendExtraBrowserArg('--my-lovely-command-line-arg')To report the value of a UMA histogram, call domAutomationController.getHistogram() from JavaScript. For example:def CustomizeBrowserOptions(self, options): options.AppendExtraBrowserArg('--dom-automation') options.AppendExtraBrowserArg('--reduce-security-for-dom-automation-tests')def MeasurePage(self, page, tab, results): result = tab.EvaluateJavaScript('domAutomationController.getHistogram("MY_LOVELY_HISTOGRAM")') results.Add('result', 'units', result)To report the value of any events in the Inspector's timeline, call tab.timeline_model.GetAllEvents(). See loading_benchmark.py for a good example of this.Doing It All By HandBenchmarks and page_sets are the best way to use telemetry. But, if you just want to print the number of divs on google.com, for example: import telemetry options = telemetry.BrowserOptions() parser = options.CreateParser('telemetry_perf_test.py') options, args = parser.parse_args(args) browser_to_create = telemetry.FindBrowser(options) with browser_to_create.Create() as b: b.tabs[0].Navigate('http://www.google.com') print b.tabs[0].EvaluateJavaScript('document.querySelectorAll("div").length') Contact Us or Follow AlongIf you have questions, please email telemetry@chromium.org You can keep up with Telemetry related discussions and code reviews by joining the telemetry group. |
