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

Unified Diff: chrome/test/data/webrtc/peerconnection_getstats.js

Issue 2641263003: Performance measures of old and new RTCPeerConnection.getStats added. (Closed)
Patch Set: Avoiding win uninitialized variable warning Created 3 years, 11 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/data/webrtc/peerconnection_getstats.js
diff --git a/chrome/test/data/webrtc/peerconnection_getstats.js b/chrome/test/data/webrtc/peerconnection_getstats.js
index 6054a5cea7c19057127c4ec5898391e570d5ff35..7fa3333757bdf5a20da61810cde625504bcead6d 100644
--- a/chrome/test/data/webrtc/peerconnection_getstats.js
+++ b/chrome/test/data/webrtc/peerconnection_getstats.js
@@ -301,6 +301,36 @@ function getStatsReportDictionary() {
}
/**
+ * Measures the performance of the promise-based |RTCPeerConnection.getStats|
+ * and returns the time it took in milliseconds as a double
+ * (DOMHighResTimeStamp, accurate to one thousandth of a millisecond).
+ * Verifies that all stats types of the whitelist were contained in the result.
+ *
+ * Returns "ok-" followed by a double on success.
+ */
+function measureGetStatsPerformance() {
+ let t0 = performance.now();
+ peerConnection_().getStats()
+ .then(function(report) {
+ let t1 = performance.now();
+ let statsTypes = new Set();
+ for (let stats of report.values()) {
+ verifyStatsIsWhitelisted_(stats);
+ statsTypes.add(stats.type);
+ }
+ if (statsTypes.size != gStatsWhitelist.size) {
+ returnToTest('The returned report contains a different number (' +
+ statsTypes.size + ') of stats types than the whitelist. ' +
+ JSON.stringify(Array.from(statsTypes)));
+ }
+ returnToTest('ok-' + (t1 - t0));
+ },
+ function(e) {
+ throw failTest('Promise was rejected: ' + e);
+ });
+}
+
+/**
* Returns a complete list of whitelisted "RTCStats.type" values as a
* JSON-stringified array of strings to the test.
*/

Powered by Google App Engine
This is Rietveld 408576698