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 --- ProcessList.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'ProcessList.h') diff --git a/ProcessList.h b/ProcessList.h index 46944dbd..7d98197d 100644 --- a/ProcessList.h +++ b/ProcessList.h @@ -48,8 +48,9 @@ typedef struct ProcessList_ { Hashtable* displayTreeSet; Hashtable* draftingTreeSet; - struct timeval timestamp; /* time of the current sample */ - uint64_t timestampMs; /* current time in milliseconds */ + struct timeval realtime; /* time of the current sample */ + uint64_t realtimeMs; /* current time in milliseconds */ + uint64_t monotonicMs; /* same, but from monotonic clock */ Panel* panel; int following; @@ -79,8 +80,6 @@ typedef struct ProcessList_ { memory_t cachedSwap; unsigned int cpuCount; - - time_t scanTs; } ProcessList; ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId); -- cgit v1.2.3