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

Unified 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: Fix GN build failure 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/media_router/telemetry/benchmarks/pagesets/cpu_memory_script.js
diff --git a/chrome/test/media_router/telemetry/benchmarks/pagesets/cpu_memory_script.js b/chrome/test/media_router/telemetry/benchmarks/pagesets/cpu_memory_script.js
new file mode 100644
index 0000000000000000000000000000000000000000..06da0a82ccbad37af6e021412de35c1a95f67733
--- /dev/null
+++ b/chrome/test/media_router/telemetry/benchmarks/pagesets/cpu_memory_script.js
@@ -0,0 +1,55 @@
+/**
+ * Copyright 2016 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * @fileoverview Script to interact with test extension to get CPU/memory usage.
+ *
+ */
+
+
+// MR test extension ID.
+var extensionId = 'ocihafebdemjoofhbdnamghkfobfgbal';
+
+/**
+ * The dictionary to store the performance results with the following format:
+ * key: the metric, e.g. CPU, private memory
+ * value: map of the performance results for different processes.
+ * key: process type, e.g. tab, browser, gpu, extension.
+ * value: list of the performance results.
+ */
+window.perfResults = {};
+
+/**
+ * Connects to the test extension and starts to collect CPU/memory usage data.
+ */
+function collectPerfData() {
+ processCpuPort_ = openPort_('collectData');
+ if (processCpuPort_) {
+ processCpuPort_.onMessage.addListener(function(message) {
+ for (metric in message) {
+ if (!window.perfResults[metric]) {
+ window.perfResults[metric] = {};
+ }
+ for (process_type in message[metric]) {
+ if (!window.perfResults[metric][process_type]) {
+ window.perfResults[metric][process_type] = []
+ }
+ window.perfResults[metric][process_type].push(
+ message[metric][process_type]);
+ }
+ }
+ });
+ } else {
+ console.log('Unable to connect to port');
+ }
+}
+
+function openPort_(name) {
+ var rt = window.chrome.runtime;
+ if (rt && rt.connect) {
+ console.info('Opening port named ' + name);
+ return rt.connect(extensionId, {'name': name});
+ }
+ return null;
+}

Powered by Google App Engine
This is Rietveld 408576698