Commit Graph

25 Commits

Author SHA1 Message Date
Nathan Scott 356488aa53 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
2021-04-05 23:41:07 +02:00
Sohaib 421bdeec60 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
2021-04-05 23:40:41 +02:00
Christian Göttsche 2d1042adb3 Save text buffer in Meter 2021-03-04 23:57:45 +01:00
Christian Göttsche d72b0a682e Mark several non-modified pointer variables const 2021-01-11 20:12:34 +01:00
Christian Göttsche e1ce141bc3 Use size_t as len type for Meter_UpdateValues
Most of the time the parameter is passed to snprintf type functions
2020-12-06 16:03:44 +01:00
Benny Baumann 61e14d4bb2 Spacing around operators 2020-11-02 22:15:01 +01:00
Benny Baumann 0f5262917f Make all required includes explicit
Information as seen by IWYU 0.12 + clang 9 on Linux
2020-10-18 20:09:05 +02:00
Christian Göttsche ba282cfe19 Mark Object instances const 2020-10-07 13:01:53 +02:00
Daniel Lange 079c2abf8e Update License consistently to GPLv2 as per COPYING file 2020-10-05 10:13:12 +02:00
Christian Göttsche 6db2d52261 Covert Meter attributes to file-local constant arrays 2020-09-29 10:44:42 +02:00
Zev Weiss a1a027b9bd Axe automated header generation.
Reasoning:
 - implementation was unsound -- broke down when I added a fairly
   basic macro definition expanding to a struct initializer in a *.c
   file.

 - made it way too easy (e.g. via otherwise totally innocuous git
   commands) to end up with timestamps such that it always ran
   MakeHeader.py but never used its output, leading to overbuild noise
   when running what should be a null 'make'.

 - but mostly: it's just an awkward way of dealing with C code.
2020-09-03 11:58:58 -05:00
Explorer09 9dea20e068 Rename Meter.setValues() functions to updateValues()
Rationale (copied from htop issue #471):
The function name "setValues" is misleading. For most OOP (object-
oriented programming) contexts, setXXX functions mean they will change
some member variables of an object into something specified in
function arguments. But in the *Meter_setValues() case, the new values
are not from the arguments, but from a hard-coded source. The caller
is not supposed to change the values[] to anything it likes, but
rather to "update" the values from the source. Hence, updateValues is
a better name for this family of functions.
2016-05-04 13:39:26 +08:00
Explorer09 99fb3070a2 Explicit "maxItems" property of meters
Two changes in this commit:
- All meters now explicitly specify "maxItems" property, even for just
  1 item. (Exception is "container" CPU meter classes, which use
  CUSTOM_METERMODE.)
- "maxItems" being 0 is now allowed. This will let bar meters and graph
  meters render an empty meter.
2016-03-11 10:54:34 +08:00
Christian Hesse 804bd37dca get a useful tolal for clock meter 2015-08-28 10:15:00 +02:00
Hisham Muhammad f5a469b5a8 Use reentrant version to silence warnings. 2014-04-21 18:59:30 -03:00
Hisham Muhammad c1e0f6e17c BUGFIX: Fix crash when adding meters and toggling detailed CPU time.
See https://bugzilla.redhat.com/show_bug.cgi?id=987805 for details.
(thanks to Dawid Gajownik for the detailed analysis!)
2014-01-16 01:40:47 -02:00
Hisham Muhammad 00b324bfc1 Changes in object model: separate class objects to store vtable. Also, nicer UTF-8 display of big numbers. 2012-12-05 15:12:20 +00:00
Hisham Muhammad 45f7a4fc8d Remove old memory debugging routines. We have Valgrind nowadays. 2011-12-26 22:04:29 +00:00
Hisham Muhammad 84281bdc44 major header cleanup 2011-12-26 21:35:57 +00:00
Hisham Muhammad 300caa076e Tempus fugit. 2011-05-26 16:35:07 +00:00
Hisham Muhammad a600d5a6e9 Tempus fugit. 2010-02-25 02:08:18 +00:00
Hisham Muhammad da23c8c5a1 Clean up headers by using 'static' whenever possible.
Reduces resulting code size.
2008-03-09 08:58:38 +00:00
Hisham Muhammad 2f1f82ee87 Updates for new version of the MakeHeader.py script. 2006-06-06 20:41:01 +00:00
Hisham Muhammad 33113fe0d7 - Overhaul meters implementation;
- add AllCPUsMeter;
- because of that, the new .htoprc is incompatible with previous released versions.
2006-04-10 20:40:38 +00:00
Hisham Muhammad d6231bab89 Initial import. 2006-03-04 18:16:49 +00:00