public class RateCalculator extends Object
TickSource)1 - prescale ticks are skipped before actually allowing data to
be sent or received). This is a possibility of skipping ticks to allow for
very low bitrates without having extensive tick intervals.MIN_INTERVAL_NS nanoseconds to avoid overhead by CPU usage.MAX_INTERVAL_NS ns.SCALE) is tested by
RateCalculatorTest (in test sources).| Modifier and Type | Class and Description |
|---|---|
static class |
RateCalculator.Result |
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_BYTES_PER_TICK
The enforced upper bound for bytes per tick.
|
static double |
MAX_ERROR
The error margin permitted for calculations.
|
static int |
MAX_INTERVAL_NS
The enforced upper bound for the interval.
|
static float |
MAX_RATE
The highest byte rate representable with our data model (this is not
necessarily the exact maximum value, but a value close enough to the
maximum upper bound.
|
static int |
MIN_INTERVAL_NS
The default enforced lower bound for the interval.
|
static float |
MIN_RATE
The minimum byte rate representable with our data model (this is not
necessarily the exact minimum value, but a value close enough to the
minimum lower bound.
|
static int |
NS_PER_S
Nanoseconds per second.
|
static RoundingMode |
ROUND
The rounding mode (see
BigDecimal) used for internal calculation. |
static int |
SCALE
The scale (see
BigDecimal) used for internal calculations. |
| Modifier and Type | Method and Description |
|---|---|
static RateCalculator.Result |
calculate(float rateBytesPerSecond)
Performs a calculation with the default minimal interval (see
MIN_INTERVAL_NS). |
static RateCalculator.Result |
calculate(float rateBytesPerSecond,
int minInterval)
Performs a calculation with the given minimal interval.
|
public static final float MIN_RATE
public static final float MAX_RATE
public static final int NS_PER_S
public static final int MIN_INTERVAL_NS
public static final int MAX_INTERVAL_NS
public static final int MAX_BYTES_PER_TICK
public static final int SCALE
BigDecimal) used for internal calculations.public static final RoundingMode ROUND
BigDecimal) used for internal calculation.public static final double MAX_ERROR
public static RateCalculator.Result calculate(float rateBytesPerSecond)
MIN_INTERVAL_NS). See RateCalculator for details.rateBytesPerSecond - The rate in bytes per second to targetpublic static RateCalculator.Result calculate(float rateBytesPerSecond, int minInterval)
RateCalculator for details.rateBytesPerSecond - The rate in bytes per second to targetminInterval - The minimal interval in nanoseconds.Copyright © 2015. All rights reserved.