summaryrefslogtreecommitdiffstats
path: root/Machine.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2023-08-29 13:02:50 +0200
committercgzones <cgzones@googlemail.com>2024-03-27 19:49:23 +0100
commitb61685779cdf696ba4135a97ce66075c337c7562 (patch)
tree03cde66b2157eb5da9b0bc64fa46bff01ea96767 /Machine.c
parent484f029d8b0e0dbb5df37e3aff0dbf059fd857a1 (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.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Machine.c b/Machine.c
index 44aa27c8..6beb47b4 100644
--- a/Machine.c
+++ b/Machine.c
@@ -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();

© 2014-2024 Faster IT GmbH | imprint | privacy policy