public class FrameTimer
extends java.lang.Object
FrameTimer
object at the top of a sketch, initialise it in the setup()
method, and
call one and only one of the methods for reporting frame rates (displayFrameRate()
,
getFrameRate()
, getFrameRateAsText()
) in the draw()
method. Frame rates can be reported either every n frames or every t seconds
depending on which constructor is used.Constructor and Description |
---|
FrameTimer()
Creates a timer that will report the frame rate once in every 50 frames.
|
FrameTimer(float delay,
float reportRateInSeconds)
Creates a timer that will report the frame rate once in every
reportRateInSeconds seconds. |
FrameTimer(int reportRateInFrames)
Creates a timer that will report the frame rate once in every
reportRateInFrames frames. |
Modifier and Type | Method and Description |
---|---|
void |
displayFrameRate()
Displays the current frame rate.
|
float |
getElapsedTime()
Retrieves the time since the last call to
startTimer() |
float |
getFrameRate()
Reports the current frame rate as a number.
|
java.lang.String |
getFrameRateAsText()
Reports the current frame rate as formatted text.
|
void |
startTimer()
Starts a timer that can be used for timing specific parts of a program.
|
void |
update()
Updates the frame counter.
|
public FrameTimer()
public FrameTimer(int reportRateInFrames)
reportRateInFrames
frames.reportRateInFrames
- Number of frames to elapse before recalculation of the current frame rate.public FrameTimer(float delay, float reportRateInSeconds)
reportRateInSeconds
seconds.delay
- Number of seconds delay before the first frame rate calculation. This can be useful if you
wish to ignore frame rates during the initialisation part of a sketch.reportRateInSeconds
- Number of seconds between recalculations of the current frame rate.public void displayFrameRate()
public java.lang.String getFrameRateAsText()
public float getFrameRate()
public void update()
public void startTimer()
getElapsedTime
to retrieve the number of seconds since a call was made to this method.public float getElapsedTime()
startTimer()
startTimer
was last called, or 0 if it has not been called.