summaryrefslogtreecommitdiffstats
path: root/Process.h
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-04-14 20:16:16 +0200
committercgzones <cgzones@googlemail.com>2021-04-26 18:02:58 +0200
commitb41e4d9c546e95fb308db3308848d7dddb4d98cf (patch)
tree77ba38e2fdd1750ff3653d469015448c74515ab3 /Process.h
parent6bbb454881986a1a4d2e639b5fb6b7ac47374fe2 (diff)
Rework process field print functions
Make functions formatting data for a process field column less error prone, unify interfaces and improve some internals. * Process_printBytes - rename from Process_humanNumber - take number in bytes, not kilobytes - handle petabytes - increase buffer to avoid crashes when the passed value is ~ ULLONG_MAX * Process_printKBytes - add wrapper for Process_printBytes taking kilobytes keeping -1 as special value * Process_printCount - rename from Process_colorNumber * Process_printTime - add coloring parameter as other print functions - improve coloring and formatting for larger times * Process_printRate - rename from Process_outputRate - use local buffer instead of passed one; this function prints to the RichString after all
Diffstat (limited to 'Process.h')
-rw-r--r--Process.h23
1 files changed, 14 insertions, 9 deletions
diff --git a/Process.h b/Process.h
index a0bdea74..9887bd13 100644
--- a/Process.h
+++ b/Process.h
@@ -245,27 +245,32 @@ static inline bool Process_isChildOf(const Process* this, pid_t pid) {
#define ONE_M (ONE_K * ONE_K)
#define ONE_G (ONE_M * ONE_K)
#define ONE_T (1ULL * ONE_G * ONE_K)
+#define ONE_P (1ULL * ONE_T * ONE_K)
#define ONE_DECIMAL_K 1000UL
#define ONE_DECIMAL_M (ONE_DECIMAL_K * ONE_DECIMAL_K)
#define ONE_DECIMAL_G (ONE_DECIMAL_M * ONE_DECIMAL_K)
#define ONE_DECIMAL_T (1ULL * ONE_DECIMAL_G * ONE_DECIMAL_K)
+#define ONE_DECIMAL_P (1ULL * ONE_DECIMAL_T * ONE_DECIMAL_K)
void Process_setupColumnWidths(void);
-/* Takes number in kilo units (base 1024) */
-void Process_humanNumber(RichString* str, unsigned long long number, bool coloring);
+/* Takes number in bytes (base 1024). Prints 6 columns. */
+void Process_printBytes(RichString* str, unsigned long long number, bool coloring);
-/* Takes number in bare units (base 1000) */
-void Process_colorNumber(RichString* str, unsigned long long number, bool coloring);
+/* Takes number in kilo bytes (base 1024). Prints 6 columns. */
+void Process_printKBytes(RichString* str, unsigned long long number, bool coloring);
-/* Takes number in hundredths of a seconds */
-void Process_printTime(RichString* str, unsigned long long totalHundredths);
+/* Takes number as count (base 1000). Prints 12 columns. */
+void Process_printCount(RichString* str, unsigned long long number, bool coloring);
-void Process_fillStarttimeBuffer(Process* this);
+/* Takes time in hundredths of a seconds. Prints 9 columns. */
+void Process_printTime(RichString* str, unsigned long long totalHundredths, bool coloring);
+
+/* Takes rate in bare unit (base 1024) per second. Prints 12 columns. */
+void Process_printRate(RichString* str, double rate, bool coloring);
-/* Takes number in bare units (base 1024) */
-void Process_outputRate(RichString* str, char* buffer, size_t n, double rate, int coloring);
+void Process_fillStarttimeBuffer(Process* this);
void Process_printLeftAlignedField(RichString* str, int attr, const char* content, unsigned int width);

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