org.gicentre.utils
Class FrameTimer

java.lang.Object
  extended by org.gicentre.utils.FrameTimer

public class FrameTimer
extends java.lang.Object

Class for displaying frame rates in a sketch. To use, declare a FrameTimer object at the top of a sketch, initialise it in the setup() method, and call displayFrameRate() in the draw() method.

Version:
3.0, 10th August, 2010.
Author:
Jo Wood, giCentre, City University London.

Constructor Summary
FrameTimer()
          Creates a timer that will report the frame rate once in every 50 frames.
FrameTimer(int reportRate)
          Creates a timer that will report the frame rate once in every reportRate frames.
 
Method Summary
 void displayFrameRate()
          Displays the current frame rate.
 float getElapsedTime()
          Retrieves the time since the last call to startTimer()
 void startTimer()
          Starts a timer that can be used for timing specific parts of a programming.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FrameTimer

public FrameTimer()
Creates a timer that will report the frame rate once in every 50 frames.


FrameTimer

public FrameTimer(int reportRate)
Creates a timer that will report the frame rate once in every reportRate frames.

Parameters:
reportRate - Number of frames to elapse before reporting current frame rate.
Method Detail

displayFrameRate

public void displayFrameRate()
Displays the current frame rate. This method must be called every time a new frame is drawn, but will only display results one in every reportRate frames.


startTimer

public void startTimer()
Starts a timer that can be used for timing specific parts of a programming. Call getElapsedTime to retrieve the number of seconds since a call was made to this method.


getElapsedTime

public float getElapsedTime()
Retrieves the time since the last call to startTimer()

Returns:
Time in seconds since startTimer was last called, or 0 if it has not been called.


gicentreUtils V.3.0, API documentation generated 13th August, 2010