Pre-calculate intervalInSecond in LeapArray to reduce redundant calculation (#1700)
This commit is contained in:
parent
b91305a903
commit
d5eb5f473f
|
|
@ -43,6 +43,7 @@ public abstract class LeapArray<T> {
|
||||||
protected int windowLengthInMs;
|
protected int windowLengthInMs;
|
||||||
protected int sampleCount;
|
protected int sampleCount;
|
||||||
protected int intervalInMs;
|
protected int intervalInMs;
|
||||||
|
private double intervalInSecond;
|
||||||
|
|
||||||
protected final AtomicReferenceArray<WindowWrap<T>> array;
|
protected final AtomicReferenceArray<WindowWrap<T>> array;
|
||||||
|
|
||||||
|
|
@ -64,6 +65,7 @@ public abstract class LeapArray<T> {
|
||||||
|
|
||||||
this.windowLengthInMs = intervalInMs / sampleCount;
|
this.windowLengthInMs = intervalInMs / sampleCount;
|
||||||
this.intervalInMs = intervalInMs;
|
this.intervalInMs = intervalInMs;
|
||||||
|
this.intervalInSecond = intervalInMs / 1000.0;
|
||||||
this.sampleCount = sampleCount;
|
this.sampleCount = sampleCount;
|
||||||
|
|
||||||
this.array = new AtomicReferenceArray<>(sampleCount);
|
this.array = new AtomicReferenceArray<>(sampleCount);
|
||||||
|
|
@ -393,7 +395,7 @@ public abstract class LeapArray<T> {
|
||||||
* @return interval in second
|
* @return interval in second
|
||||||
*/
|
*/
|
||||||
public double getIntervalInSecond() {
|
public double getIntervalInSecond() {
|
||||||
return intervalInMs / 1000.0;
|
return intervalInSecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debug(long time) {
|
public void debug(long time) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue