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

Side by Side Diff: chrome/test/data/webrtc/peerconnection.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 unified diff | Download patch
OLDNEW
1 /** 1 /**
2 * Copyright 2014 The Chromium Authors. All rights reserved. 2 * Copyright 2014 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /** 7 /**
8 * The one and only peer connection in this page. 8 * The one and only peer connection in this page.
9 * @private 9 * @private
10 */ 10 */
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 369 }
370 370
371 /** 371 /**
372 * Returns 372 * Returns
373 */ 373 */
374 function hasSeenCryptoInSdp() { 374 function hasSeenCryptoInSdp() {
375 returnToTest(gHasSeenCryptoInSdp); 375 returnToTest(gHasSeenCryptoInSdp);
376 } 376 }
377 377
378 /** 378 /**
379 * Verifies that |RTCPeerConnection.getStats| returns stats. 379 * Verifies that the legacy |RTCPeerConnection.getStats| returns stats and
380 * verifies that each stats member is a string.
380 * 381 *
381 * Returns ok-got-stats on success. 382 * Returns ok-got-stats on success.
382 */ 383 */
383 function verifyStatsGenerated() { 384 function verifyStatsGenerated() {
384 peerConnection_().getStats( 385 peerConnection_().getStats(
385 function(response) { 386 function(response) {
386 var reports = response.result(); 387 var reports = response.result();
387 var numStats = 0; 388 var numStats = 0;
388 for (var i = 0; i < reports.length; i++) { 389 for (var i = 0; i < reports.length; i++) {
389 var statNames = reports[i].names(); 390 var statNames = reports[i].names();
390 numStats += statNames.length; 391 numStats += statNames.length;
391 for (var j = 0; j < statNames.length; j++) { 392 for (var j = 0; j < statNames.length; j++) {
392 var statValue = reports[i].stat(statNames[j]); 393 var statValue = reports[i].stat(statNames[j]);
393 if (typeof statValue != 'string') 394 if (typeof statValue != 'string')
394 throw failTest('A stat was returned that is not a string.'); 395 throw failTest('A stat was returned that is not a string.');
395 } 396 }
396 } 397 }
397 if (numStats === 0) 398 if (numStats === 0)
398 throw failTest('No stats was returned by getStats.'); 399 throw failTest('No stats was returned by getStats.');
399 returnToTest('ok-got-stats'); 400 returnToTest('ok-got-stats');
400 }); 401 });
401 } 402 }
402 403
404 /**
405 * Measures the performance of the legacy (callback-based)
406 * |RTCPeerConnection.getStats| and returns the time it took in milliseconds as
407 * a double (DOMHighResTimeStamp, accurate to one thousandth of a millisecond).
408 *
409 * Returns "ok-" followed by a double.
410 */
411 function measureGetStatsCallbackPerformance() {
412 let t0 = performance.now();
413 peerConnection_().getStats(
414 function(response) {
415 let t1 = performance.now();
416 returnToTest('ok-' + (t1 - t0));
417 });
418 }
419
403 // Internals. 420 // Internals.
404 421
405 /** @private */ 422 /** @private */
406 function createPeerConnection_(rtcConfig) { 423 function createPeerConnection_(rtcConfig) {
407 try { 424 try {
408 peerConnection = new RTCPeerConnection(rtcConfig, {}); 425 peerConnection = new RTCPeerConnection(rtcConfig, {});
409 } catch (exception) { 426 } catch (exception) {
410 throw failTest('Failed to create peer connection: ' + exception); 427 throw failTest('Failed to create peer connection: ' + exception);
411 } 428 }
412 peerConnection.onaddstream = addStreamCallback_; 429 peerConnection.onaddstream = addStreamCallback_;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 function parseJson_(json) { 477 function parseJson_(json) {
461 // Escape since the \r\n in the SDP tend to get unescaped. 478 // Escape since the \r\n in the SDP tend to get unescaped.
462 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n'); 479 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n');
463 try { 480 try {
464 return JSON.parse(jsonWithEscapedLineBreaks); 481 return JSON.parse(jsonWithEscapedLineBreaks);
465 } catch (exception) { 482 } catch (exception) {
466 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' + 483 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' +
467 exception); 484 exception);
468 } 485 }
469 } 486 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698