Class OPSMeter

java.lang.Object
com.wualabs.qtsurfer.common.util.OPSMeter

public final class OPSMeter extends Object
Lightweight operations-per-second meter. Call count() on each operation; the meter reports a smoothed current rate via getOps() and the lifetime operation count via getProcessed().

The rate is an exponential moving average of the instantaneous per-operation rate (the reciprocal of the interval since the previous operation), so it tracks recent throughput and decays as activity slows. This is deliberately not the lifetime average processed / totalElapsed, which barely moves once many operations have accumulated and therefore never reflects a current slowdown or burst.

All mutating and reading methods are synchronized: count() is invoked from multiple delivery threads on the market-data fan-in paths (per-instrument ticker/order-book streams feed a shared meter), where an unsynchronized processed++ silently loses increments.

  • Constructor Details

    • OPSMeter

      public OPSMeter(@NonNull @NonNull String name)
  • Method Details

    • reset

      public void reset()
    • count

      public void count()
      Records one operation and updates the smoothed current rate. The first call (or the first after reset()) only establishes the timing baseline. Subsequent calls fold the instantaneous rate for the elapsed interval into the moving average; operations landing within the same nanosecond (concurrent delivery) still count but do not perturb the rate.
    • getProcessed

      public long getProcessed()
    • getOps

      public float getOps()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getName

      public String getName()