public class TPS extends java.lang.Object implements Loggeable
It can operate in two different modes:
When operating in auto update mode, a Timer is created and the number of transactions (calls to tick()) is automatically calculated for every period. Under this mode, user has to call the stop() method when this TPS object is no longer needed, otherwise it will keep a Thread lingering around.
When operating in manual update mode, user has to call one of its floatValue() or intValue() method at regular intervals. The returned value will be the average TPS for the given period since the last call
.Modifier and Type | Field and Description |
---|---|
protected long |
simulatedNanoTime |
Constructor and Description |
---|
TPS() |
TPS(boolean autoupdate) |
TPS(long period,
boolean autoupdate) |
Modifier and Type | Method and Description |
---|---|
void |
dump(java.io.PrintStream p,
java.lang.String indent) |
float |
floatValue() |
float |
getAvg() |
long |
getElapsed() |
protected long |
getNanoTime() |
int |
getPeak() |
long |
getPeakWhen() |
long |
getPeriod() |
int |
intValue() |
void |
reset()
resets average and peak
|
void |
setSimulatedNanoTime(long simulatedNanoTime) |
void |
stop() |
void |
tick() |
java.lang.String |
toString() |
public TPS()
public TPS(boolean autoupdate)
autoupdate
- true to auto updatepublic TPS(long period, boolean autoupdate)
period
- in millisautoupdate
- true to autoupdatepublic void tick()
public float floatValue()
public int intValue()
public float getAvg()
public int getPeak()
public long getPeakWhen()
public void reset()
public long getPeriod()
public long getElapsed()
public java.lang.String toString()
toString
in class java.lang.Object
public void stop()
public void dump(java.io.PrintStream p, java.lang.String indent)
public void setSimulatedNanoTime(long simulatedNanoTime)
protected long getNanoTime()