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

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: Minor update for the function docs 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 console.log('message: ' + message);
31 for (metric in message) {
32 if (!window.perfResults[metric]) {
33 window.perfResults[metric] = {};
34 }
35 for (process_type in message[metric]) {
36 if (!window.perfResults[metric][process_type]) {
37 window.perfResults[metric][process_type] = []
38 }
39 window.perfResults[metric][process_type].push(
40 message[metric][process_type]);
41 }
42 }
43 });
44 } else {
45 console.log('Unable to connect to port');
46 return;
47 }
48 }
49
50 function openPort_(name) {
51 var rt = window.chrome.runtime;
52 if (rt && rt.connect) {
53 console.log('Opening port named ' + name);
54 return rt.connect(extensionId, {'name': name});
55 }
56 return null;
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698