public boolean frame(){
  frameCount++;
  long time=System.currentTimeMillis();
  if (periodStart <= 0)   periodStart=time;
  long elapsed=time - periodStart;
  if (elapsed >= 1000) {
    currentFPS=(1000 * frameCount) / (float)elapsed;
    frameCount=0;
    periodStart=time;
    return true;
  }
  return false;
}

public boolean frame ( ) { frameCount ++ ; long time = System . currentTimeMillis ( ) ; if ( periodStart <= 0 ) periodStart = time ; long elapsed = time - periodStart ; if ( elapsed >= 1000 ) { currentFPS = ( 1000 * frameCount ) / ( float ) elapsed ; frameCount = 0 ; periodStart = time ; return true ; } return false ; }
call this function during each frame . the count of elapsed frames will be increased and if a second has elapsed since the last fps calculation , a new fps value will be calculated . if this happens , then the function will return true .
