Selaa lähdekoodia

Make benchmark results available from outside

Dominic Szablewski 11 vuotta sitten
vanhempi
commit
a181ced147
1 muutettua tiedostoa jossa 3 lisäystä ja 2 poistoa
  1. 3 2
      jsmpg.js

+ 3 - 2
jsmpg.js Näytä tiedosto

414
 jsmpeg.prototype.benchmark = false;
414
 jsmpeg.prototype.benchmark = false;
415
 jsmpeg.prototype.benchFrame = 0;
415
 jsmpeg.prototype.benchFrame = 0;
416
 jsmpeg.prototype.benchDecodeTimes = 0;
416
 jsmpeg.prototype.benchDecodeTimes = 0;
417
+jsmpeg.prototype.benchAvgFrameTime = 0;
417
 
418
 
418
 jsmpeg.prototype.now = function() {
419
 jsmpeg.prototype.now = function() {
419
 	return window.performance 
420
 	return window.performance 
466
 	if( this.benchmark ) {
467
 	if( this.benchmark ) {
467
 		this.benchFrame++;
468
 		this.benchFrame++;
468
 		if( this.benchFrame >= 120 ) {
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
 			this.benchFrame = 0;
471
 			this.benchFrame = 0;
472
 			this.benchDecodeTimes = 0;
472
 			this.benchDecodeTimes = 0;
473
+			if( window.console ) { console.log("Average time per frame:", this.benchAvgFrameTime, 'ms'); }
473
 		}
474
 		}
474
 		setTimeout( this.nextFrame.bind(this), 0);
475
 		setTimeout( this.nextFrame.bind(this), 0);
475
 	}
476
 	}