void performFPSCalculations(){
  numberOfFrames+=1;
  long currentTime=SystemClock.elapsedRealtime();
  if (currentTime > timeToUpdate) {
    float framesPerSecond=(numberOfFrames / (float)(currentTime - firstSystemTime)) * 1000f;
    fpsPct.setText(String.format(" %.1f",framesPerSecond));
    timeToUpdate=currentTime + 1000L;
  }
}

void performFPSCalculations ( ) { numberOfFrames += 1 ; long currentTime = SystemClock . elapsedRealtime ( ) ; if ( currentTime > timeToUpdate ) { float framesPerSecond = ( numberOfFrames / ( float ) ( currentTime - firstSystemTime ) ) * 1000f ; fpsPct . setText ( String . format ( " %.1f" , framesPerSecond ) ) ; timeToUpdate = currentTime + 1000L ; } }
fps measurement simply uses systemclock to measure how many frames were processed since the fps variables were last reset . the constants 1000l and 1000f appear because . elapsedrealtime ( ) measures time in milliseconds . note that if 20 frames per second are processed , this method could run for 1 . 5 years without being reset before numberofframes overflows .
