Class SbkRateController
java.lang.Object
io.sbk.api.impl.SbkRateController
- All Implemented Interfaces:
RateController
Simple rate controller used by SBK to pace operations to a target
records-per-second value.
The controller computes an average inter-record sleep time in nanoseconds and accumulates fractional sleep time to decide when to perform an actual Thread.sleep with millisecond+nanosecond precision. This avoids sleeping on every operation while preserving long-term throughput accuracy.
Notes:
- If
recordsPerSecis zero or negative the controller is inactive. - Sleep durations smaller than
MIN_SLEEP_NSare accumulated and coalesced before a blocking sleep is issued to avoid excessive context switches.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
SbkRateController
public SbkRateController()
-
-
Method Details
-
start
public void start(int recordsPerSec) Start the Rate Controller.- Specified by:
startin interfaceRateController- Parameters:
recordsPerSec- Records Per Second.
-
control
public void control(long events, double elapsedSec) Blocks for small amounts of time to achieve target Throughput/events per sec.- Specified by:
controlin interfaceRateController- Parameters:
events- current cumulative eventselapsedSec- Elapsed seconds
-