From 356488aa53e8c0bedeb7641685d931c8900098c5 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Tue, 30 Mar 2021 15:55:48 +1100 Subject: Request the realtime and monotonic clock times once per sample Refactor the sample time code to make one call to gettimeofday (aka the realtime clock in clock_gettime, when available) and one to the monotonic clock. Stores each in more appropriately named ProcessList fields for ready access when needed. Every platform gets the opportunity to provide their own clock code, and the existing Mac OS X specific code is moved below darwin instead of in Compat. A couple of leftover time(2) calls are converted to use these ProcessList fields as well, instead of yet again sampling the system clock. Related to https://github.com/htop-dev/htop/pull/574 --- DiskIOMeter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'DiskIOMeter.c') diff --git a/DiskIOMeter.c b/DiskIOMeter.c index c1b35690..dd2e3c46 100644 --- a/DiskIOMeter.c +++ b/DiskIOMeter.c @@ -34,7 +34,7 @@ static void DiskIOMeter_updateValues(Meter* this) { const ProcessList* pl = this->pl; static uint64_t cached_last_update; - uint64_t passedTimeInMs = pl->timestampMs - cached_last_update; + uint64_t passedTimeInMs = pl->realtimeMs - cached_last_update; /* update only every 500ms */ if (passedTimeInMs > 500) { @@ -43,7 +43,7 @@ static void DiskIOMeter_updateValues(Meter* this) { static uint64_t cached_msTimeSpend_total; uint64_t diff; - cached_last_update = pl->timestampMs; + cached_last_update = pl->realtimeMs; DiskIOData data; -- cgit v1.2.3