Home | History | Annotate | Download | only in src
      1 crosFrameData = function(seq, startTime, frameElapsedTime, jsElapsedTime) {
      2   this.seq = seq;
      3   this.startTime = startTime;
      4   this.frameElapsedTime = frameElapsedTime;
      5   this.jsElapsedTime = jsElapsedTime;
      6 }
      7 
      8 crosFpsCounter = 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 
     16 crosFpsCounter.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 
     25 crosFpsCounter.prototype.reset = function() {
     26   this.totalFrameElapsedTime = 0.0;
     27   this.totalJSElapsedTime = 0.0;
     28   this.totalFrames = 0;
     29   this.frameDataBuf = new Array();
     30 }
     31 
     32 crosFpsCounter.prototype.getAvgFps = function() {
     33   return this.totalFrames / this.totalFrameElapsedTime;
     34 }
     35 
     36 crosFpsCounter.prototype.getAvgRenderTime = function() {
     37   return this.totalJSElapsedTime / this.totalFrames;
     38 }
     39 
     40 crosFpsCounter.prototype.getFrameData = function() {
     41   return this.frameDataBuf;
     42 }
     43