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

Side by Side Diff: chrome/test/media_router/telemetry/benchmarks/pagesets/cpu_memory_script.js

Issue 1843063004: Add new Telemetry tests to get CPU and memory usage for idle and flinging two test scenarios. Mirro… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small change in media_router_cpu_memory_metric.py and revert the console.log to the original versio… Created 4 years, 8 months 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
OLDNEW
(Empty)
1 /**
2 * Copyright 2016 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 *
6 * @fileoverview Script to interact with test extension to get CPU/memory usage.
7 *
8 */
9
10
11 // MR test extension ID.
12 var extensionId = 'ocihafebdemjoofhbdnamghkfobfgbal';
13
14 /**
15 * The dictionary to store the performance results with the following format:
16 * key: the metric, e.g. CPU, private memory
17 * value: map of the performance results for different processes.
18 * key: process type, e.g. tab, browser, gpu, extension.
19 * value: list of the performance results.
20 */
21 window.perfResults = {};
22
23 /**
24 * Connects to the test extension and starts to collect CPU/memory usage data.
25 */
26 function collectPerfData() {
27 processCpuPort_ = openPort_('collectData');
28 if (processCpuPort_) {
29 processCpuPort_.onMessage.addListener(function(message) {
30 for (metric in message) {
31 if (!window.perfResults[metric]) {
32 window.perfResults[metric] = {};
33 }
34 for (process_type in message[metric]) {
35 if (!window.perfResults[metric][process_type]) {
36 window.perfResults[metric][process_type] = []
37 }
38 window.perfResults[metric][process_type].push(
39 message[metric][process_type]);
40 }
41 }
42 });
43 } else {
44 console.log('Unable to connect to port');
45 return;
apacible 2016/04/14 17:35:20 nit: return not needed
Lei Lei 2016/04/14 20:05:46 Done.
46 }
47 }
48
49 function openPort_(name) {
50 var rt = window.chrome.runtime;
51 if (rt && rt.connect) {
52 console.info('Opening port named ' + name);
53 return rt.connect(extensionId, {'name': name});
54 }
55 return null;
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698