summaryrefslogtreecommitdiffstats
path: root/DiskIOMeter.c
diff options
context:
space:
mode:
authorSohaib <sohaib.amhmd@gmail.com>2021-03-23 08:27:05 +0200
committerSohaib <sohaib.amhmd@gmail.com>2021-04-05 23:40:41 +0200
commit421bdeec603b4fb1a4edec0e802c437fbe47fca0 (patch)
tree8be7cfd1cb7b0c3d1720d75978b27318fbc43253 /DiskIOMeter.c
parentf16aa483dd36cfdb39e9d6d4238687178f2981e8 (diff)
Merging all the points related to calculating time in one place
The end goal is to consolidate all the points in htop that can only work in live-only mode today, so that will be able to inject PCP archive mode and have a chance at it working. The biggest problem we've got at this moment is all the places that are independently asking the kernel to 'give me the time right now'. Each of those needs to be audited and ultimately changed to allow platforms to manage their own idea of time. So, all the calls to gettimeofday(2) and time(2) are potential problems. Ultimately I want to get these down to just one or two. Related to https://github.com/htop-dev/htop/pull/574
Diffstat (limited to 'DiskIOMeter.c')
-rw-r--r--DiskIOMeter.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/DiskIOMeter.c b/DiskIOMeter.c
index dde007ed..c1b35690 100644
--- a/DiskIOMeter.c
+++ b/DiskIOMeter.c
@@ -31,12 +31,10 @@ static uint32_t cached_write_diff;
static double cached_utilisation_diff;
static void DiskIOMeter_updateValues(Meter* this) {
- static uint64_t cached_last_update;
+ const ProcessList* pl = this->pl;
- struct timeval tv;
- gettimeofday(&tv, NULL);
- uint64_t timeInMilliSeconds = (uint64_t)tv.tv_sec * 1000 + (uint64_t)tv.tv_usec / 1000;
- uint64_t passedTimeInMs = timeInMilliSeconds - cached_last_update;
+ static uint64_t cached_last_update;
+ uint64_t passedTimeInMs = pl->timestampMs - cached_last_update;
/* update only every 500ms */
if (passedTimeInMs > 500) {
@@ -45,7 +43,7 @@ static void DiskIOMeter_updateValues(Meter* this) {
static uint64_t cached_msTimeSpend_total;
uint64_t diff;
- cached_last_update = timeInMilliSeconds;
+ cached_last_update = pl->timestampMs;
DiskIOData data;

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