Change the operator order of TrafficCounter to calculate the throughput to get the correct result
Motivation: Currently the last read/write throughput is calculated by first division,this will be 0 if the last read/write bytes < interval,change the order will get the correct result Modifications: Change the operator order from first do division to multiplication Result: Get the correct result instead of 0 when bytes are smaller than interval
This commit is contained in:
parent
ffda229cf4
commit
b828e823ef
@ -236,9 +236,9 @@ public class TrafficCounter {
|
|||||||
}
|
}
|
||||||
lastReadBytes = currentReadBytes.getAndSet(0);
|
lastReadBytes = currentReadBytes.getAndSet(0);
|
||||||
lastWrittenBytes = currentWrittenBytes.getAndSet(0);
|
lastWrittenBytes = currentWrittenBytes.getAndSet(0);
|
||||||
lastReadThroughput = lastReadBytes / interval * 1000;
|
lastReadThroughput = lastReadBytes * 1000 / interval;
|
||||||
// nb byte / checkInterval in ms * 1000 (1s)
|
// nb byte / checkInterval in ms * 1000 (1s)
|
||||||
lastWriteThroughput = lastWrittenBytes / interval * 1000;
|
lastWriteThroughput = lastWrittenBytes * 1000 / interval;
|
||||||
// nb byte / checkInterval in ms * 1000 (1s)
|
// nb byte / checkInterval in ms * 1000 (1s)
|
||||||
if (lastWrittenBytes > 0) {
|
if (lastWrittenBytes > 0) {
|
||||||
lastNonNullWrittenBytes = lastWrittenBytes;
|
lastNonNullWrittenBytes = lastWrittenBytes;
|
||||||
|
Loading…
Reference in New Issue
Block a user