Package com.dkt.graphics.utils
Class TPS
java.lang.Object
com.dkt.graphics.utils.TPS
This class assists in calculating how many times something happens
 on a second or to calculate the mean time between calls.
Please note that this class was designed to be used for debugging or counting small things, when the action is executed more than 1e15 times the error in the total average
Please note that this class was designed to be used for debugging or counting small things, when the action is executed more than 1e15 times the error in the total average
tps() is very big. Also, this class uses
 System.nanoTime() so if the elapsed time between the calls to
 action() is very big, it might yield wrong results- Author:
 - Federico Vera <[email protected]>
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionvoidaction()This method is the one that tells theTPSinstance that an action has been performed.doubleRetrieves the average time in µs between calls toaction()doubleavgMilis()Retrieves the average time in ms between calls toaction()doubleavgNanos()Retrieves the average time in ns between calls toaction()doubleRetrieves the average time in µs between calls toaction(), considering only the last 50 callsdoubleRetrieves the average time in ms between calls toaction(), considering only the last 50 callslongRetrieves the average time in ns between calls toaction(), considering only the last 50 callsdoublectps()Retrieves the number of times per second that the action method has been called, considering ONLY the last 50 timesvoidreset()Resets the current object to its original statetoString()doubletps()Retrieves the number of times per second that the action method has been called 
- 
Constructor Details
- 
TPS
public TPS() 
 - 
 - 
Method Details
- 
action
public void action()This method is the one that tells theTPSinstance that an action has been performed. It should be called every time the action is executed in order for it to compute the times. - 
tps
public double tps()Retrieves the number of times per second that the action method has been called- Returns:
 - times per second
 - See Also:
 
 - 
ctps
public double ctps()Retrieves the number of times per second that the action method has been called, considering ONLY the last 50 times- Returns:
 - times per second (last 50 times)
 - See Also:
 
 - 
avgMilis
public double avgMilis()Retrieves the average time in ms between calls toaction()- Returns:
 - average time in ms
 
 - 
avgMicros
public double avgMicros()Retrieves the average time in µs between calls toaction()- Returns:
 - average time in µs
 
 - 
avgNanos
public double avgNanos()Retrieves the average time in ns between calls toaction()- Returns:
 - average time in ns
 
 - 
cAvgMilis
public double cAvgMilis()Retrieves the average time in ms between calls toaction(), considering only the last 50 calls- Returns:
 - average time in ms
 
 - 
cAvgMicros
public double cAvgMicros()Retrieves the average time in µs between calls toaction(), considering only the last 50 calls- Returns:
 - average time in µs
 
 - 
cAvgNanos
public long cAvgNanos()Retrieves the average time in ns between calls toaction(), considering only the last 50 calls- Returns:
 - average time in ns
 
 - 
reset
public void reset()Resets the current object to its original state - 
toString
 
 -