summaryrefslogtreecommitdiffstats
path: root/Meter.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 /Meter.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 'Meter.c')
-rw-r--r--Meter.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Meter.c b/Meter.c
index 6aa9f08e..b60b6933 100644
--- a/Meter.c
+++ b/Meter.c
@@ -18,6 +18,7 @@ in the source distribution for its full text.
#include "CRT.h"
#include "Macros.h"
#include "Object.h"
+#include "Platform.h"
#include "ProvideCurses.h"
#include "RichString.h"
#include "Settings.h"
@@ -286,6 +287,7 @@ static const char* const GraphMeterMode_dotsAscii[] = {
};
static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
+ const ProcessList* pl = this->pl;
if (!this->drawData) {
this->drawData = xCalloc(1, sizeof(GraphData));
@@ -312,12 +314,10 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
x += captionLen;
w -= captionLen;
- struct timeval now;
- gettimeofday(&now, NULL);
- if (!timercmp(&now, &(data->time), <)) {
+ if (!timercmp(&pl->timestamp, &(data->time), <)) {
int globalDelay = this->pl->settings->delay;
struct timeval delay = { .tv_sec = globalDelay / 10, .tv_usec = (globalDelay - ((globalDelay / 10) * 10)) * 100000 };
- timeradd(&now, &delay, &(data->time));
+ timeradd(&pl->timestamp, &delay, &(data->time));
for (int i = 0; i < nValues - 1; i++)
data->values[i] = data->values[i + 1];

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