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

Unified Diff: tools/perf/page_sets/webrtc_track_peerconnections.js

Issue 561803002: Implements peer connection stats measurements in WebRTC call test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@telemetry
Patch Set: Rebased Created 6 years, 2 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
« no previous file with comments | « tools/perf/page_sets/webrtc_cases.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/page_sets/webrtc_track_peerconnections.js
diff --git a/tools/perf/page_sets/webrtc_track_peerconnections.js b/tools/perf/page_sets/webrtc_track_peerconnections.js
new file mode 100644
index 0000000000000000000000000000000000000000..68ee11fbee5718be09c99551274c0899cfc6c1b5
--- /dev/null
+++ b/tools/perf/page_sets/webrtc_track_peerconnections.js
@@ -0,0 +1,52 @@
+// Copyright 2014 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.
+
+// This file overwrites the webkitRTCPeerConnection constructor with a
+// new constructor which tracks all created connections. It does this by
+// periodically gathering statistics on all connections, using the WebRTC
+// statistics API. All reports are gathered into window.peerConnectionReports,
+// which contains one list per connection. In each list there is a number of
+// report batches, which in turn contains metric names mapped to values.
+
+window.peerConnectionReports = [];
+
+webkitRTCPeerConnection = (function() {
+ function getReportsAsDicts(getStatsResult) {
+ var result = [];
+ getStatsResult.forEach(function(report) {
+ var values = {};
+ report.names().forEach(function(name) {
+ values[name] = report.stat(name);
+ });
+ result.push(values);
+ });
+ return result;
+ }
+
+ function gatherStatsFromOneConnection(peerConnection) {
+ var connectionId = window.peerConnectionReports.length;
+ window.peerConnectionReports.push([]);
+ var pollIntervalMs = 1000;
+
+ setInterval(function() {
+ peerConnection.getStats(function(response) {
+ var reports = getReportsAsDicts(response.result());
+ window.peerConnectionReports[connectionId].push(reports);
+ });
+ }, pollIntervalMs);
+ }
+
+ var originalConstructor = webkitRTCPeerConnection;
+ return function() {
+ // Bind the incoming arguments to the original constructor.
+ var args = [null].concat(Array.prototype.slice.call(arguments));
+ var factoryFunction = originalConstructor.bind.apply(
+ originalConstructor, args);
+
+ // Create the object and track it.
+ var peerConnection = new factoryFunction();
+ gatherStatsFromOneConnection(peerConnection);
+ return peerConnection;
+ }
+})();
« no previous file with comments | « tools/perf/page_sets/webrtc_cases.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698