Class TPS
java.lang.Object
org.jpos.util.TPS
- All Implemented Interfaces:
AutoCloseable, Loggeable
TPS can be used to measure Transactions Per Second (or transactions during
other period of time).
It can operate in two different modes:
- Auto update.
- Manual update.
When operating in auto update mode, a shared scheduler is used and the number of transactions (calls to tick()) is automatically calculated for every period. In this mode, callers should invoke stop() (or close()) when the TPS object is no longer needed to cancel its scheduled task. The shared scheduler thread is daemon and reused across instances.
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.
- Since:
- 1.6.7 r2912
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longIf set (via setSimulatedNanoTime), getNanoTime() returns this value. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
simulatedNanoTime
If set (via setSimulatedNanoTime), getNanoTime() returns this value. This is intended for deterministic tests.
-
-
Constructor Details
-
TPS
public TPS() -
TPS
- Parameters:
autoupdate- true to auto update.
-
TPS
- Parameters:
period- in millis.autoupdate- true to autoupdate.
-
-
Method Details
-
tick
-
floatValue
-
intValue
-
getAvg
-
getPeak
-
getPeakWhen
-
reset
resets average and peak. -
getPeriod
-
getElapsed
-
toString
-
stop
-
close
- Specified by:
closein interfaceAutoCloseable
-
dump
-
setSimulatedNanoTime
-
getNanoTime
-