diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2023-08-29 13:02:50 +0200 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2024-03-27 19:49:23 +0100 |
commit | b61685779cdf696ba4135a97ce66075c337c7562 (patch) | |
tree | 03cde66b2157eb5da9b0bc64fa46bff01ea96767 /Machine.c | |
parent | 484f029d8b0e0dbb5df37e3aff0dbf059fd857a1 (diff) |
Store time of the previous process scan
The difference of scans is useful for utilization calculations.
To avoid divisions by 0 on first scan set monotonicMs also on first
scan.
Diffstat (limited to 'Machine.c')
-rw-r--r-- | Machine.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -99,10 +99,14 @@ void Machine_scanTables(Machine* this) { // set scan timestamp static bool firstScanDone = false; - if (firstScanDone) - Platform_gettime_monotonic(&this->monotonicMs); - else + if (firstScanDone) { + this->prevMonotonicMs = this->monotonicMs; + } else { + this->prevMonotonicMs = 0; firstScanDone = true; + } + Platform_gettime_monotonic(&this->monotonicMs); + assert(this->monotonicMs > this->prevMonotonicMs); this->maxUserId = 0; Row_resetFieldWidths(); |