mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 05:52:31 +02:00
Don't truncate time when accumulating, and then divide by non-truncated.
This commit is contained in:
parent
3e03f85f07
commit
089e7eb6b3
1 changed files with 3 additions and 3 deletions
|
@ -22,10 +22,10 @@ class RateCounter {
|
||||||
public:
|
public:
|
||||||
void increment(size_t count = 1) {
|
void increment(size_t count = 1) {
|
||||||
auto now = usecTimestampNow();
|
auto now = usecTimestampNow();
|
||||||
auto currentIntervalMs = (uint32_t)((now - _start) / USECS_PER_MSEC);
|
float currentIntervalMs = (now - _start) / (float) USECS_PER_MSEC;
|
||||||
if (currentIntervalMs > INTERVAL) {
|
if (currentIntervalMs > (float) INTERVAL) {
|
||||||
float currentCount = _count;
|
float currentCount = _count;
|
||||||
float intervalSeconds = (float)currentIntervalMs / (float)MSECS_PER_SECOND;
|
float intervalSeconds = currentIntervalMs / (float) MSECS_PER_SECOND;
|
||||||
_rate = roundf(currentCount / intervalSeconds * _scale) / _scale;
|
_rate = roundf(currentCount / intervalSeconds * _scale) / _scale;
|
||||||
_start = now;
|
_start = now;
|
||||||
_count = 0;
|
_count = 0;
|
||||||
|
|
Loading…
Reference in a new issue