Class TPS

java.lang.Object
org.jpos.util.TPS
All Implemented Interfaces:
AutoCloseable, Loggeable

public class TPS extends Object implements Loggeable, AutoCloseable
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 Details

    • simulatedNanoTime

      protected volatile long simulatedNanoTime
      If set (via setSimulatedNanoTime), getNanoTime() returns this value. This is intended for deterministic tests.
  • Constructor Details

    • TPS

      public TPS()
    • TPS

      public TPS(boolean autoupdate)
      Parameters:
      autoupdate - true to auto update.
    • TPS

      public TPS(long period, boolean autoupdate)
      Parameters:
      period - in millis.
      autoupdate - true to autoupdate.
  • Method Details