Bläddra i källkod

Make benchmark results available from outside

Dominic Szablewski 11 år sedan
förälder
incheckning
a181ced147
1 ändrade filer med 3 tillägg och 2 borttagningar
  1. 3 2
      jsmpg.js

+ 3 - 2
jsmpg.js Visa fil

@@ -414,6 +414,7 @@ jsmpeg.prototype.targetTime = 0;
414 414
 jsmpeg.prototype.benchmark = false;
415 415
 jsmpeg.prototype.benchFrame = 0;
416 416
 jsmpeg.prototype.benchDecodeTimes = 0;
417
+jsmpeg.prototype.benchAvgFrameTime = 0;
417 418
 
418 419
 jsmpeg.prototype.now = function() {
419 420
 	return window.performance 
@@ -466,10 +467,10 @@ jsmpeg.prototype.scheduleNextFrame = function() {
466 467
 	if( this.benchmark ) {
467 468
 		this.benchFrame++;
468 469
 		if( this.benchFrame >= 120 ) {
469
-			var frameTime = this.benchDecodeTimes / this.benchFrame;
470
-			console.log("Average time per frame:", frameTime, 'ms');
470
+			this.benchAvgFrameTime = this.benchDecodeTimes / this.benchFrame;
471 471
 			this.benchFrame = 0;
472 472
 			this.benchDecodeTimes = 0;
473
+			if( window.console ) { console.log("Average time per frame:", this.benchAvgFrameTime, 'ms'); }
473 474
 		}
474 475
 		setTimeout( this.nextFrame.bind(this), 0);
475 476
 	}