1crosFrameData = function(seq, startTime, frameElapsedTime, jsElapsedTime) { 2 this.seq = seq; 3 this.startTime = startTime; 4 this.frameElapsedTime = frameElapsedTime; 5 this.jsElapsedTime = jsElapsedTime; 6} 7 8crosFpsCounter = function() { 9 this.totalElapsedTime = 0.0; 10 this.totalRenderTime = 0.0; 11 this.totalFrames = 0; 12 this.buffer_size = 120; 13 this.frameDataBuf = new Array(); 14} 15 16crosFpsCounter.prototype.update = function( 17 startTime, frameElapsedTime, jsElapsedTime) { 18 this.totalFrameElapsedTime += frameElapsedTime; 19 this.totalJSElapsedTime += jsElapsedTime; 20 this.frameDataBuf[this.totalFrames % this.buffer_size] = new crosFrameData( 21 this.totalFrames, startTime, frameElapsedTime, jsElapsedTime); 22 this.totalFrames += 1; 23} 24 25crosFpsCounter.prototype.reset = function() { 26 this.totalFrameElapsedTime = 0.0; 27 this.totalJSElapsedTime = 0.0; 28 this.totalFrames = 0; 29 this.frameDataBuf = new Array(); 30} 31 32crosFpsCounter.prototype.getAvgFps = function() { 33 return this.totalFrames / this.totalFrameElapsedTime; 34} 35 36crosFpsCounter.prototype.getAvgRenderTime = function() { 37 return this.totalJSElapsedTime / this.totalFrames; 38} 39 40crosFpsCounter.prototype.getFrameData = function() { 41 return this.frameDataBuf; 42} 43