top: provide the means to adjust scaled process memory
This commit is an unrequested outgrowth of the earlier change dealing with summary area memory field scaling. That user selectable scaling provision is now extended to include 6 (at present) task oriented memory fields. The new companion 'e' (lower case) interactive command has been added and, like the 'E' command, it can cycle each of the currently displayed memory columns between KiB through TiB. There are, however, some differences. Where '+' indicates summary area truncation at a given radix, task memory fields are automatically scaled for their column. Thus, not all rows use the same scaling. And, while summary area field widths were not changed, the task memory columns were widened in order to offer more meaningful data when the radix was increased. The precision is automatically increased in step with each radix: MiB displays 2 decimal places, GiB 3 and TiB 4. To compliment that additional precision, both the %CPU and %MEM fields were widened by 1 column and now offer precision up to 3 decimal places. But, unique to %CPU, widening could already have occurred due to the number of processors in some massively parallel boxes. At any rate, total extra width for both memory and percentage fields could amount to twenty (precious) columns more. So for both the memory and % fields the original width (along with loss of precision) can be restored via new compiler conditionals which this commit also provides. p.s. and it will be rcfile preserved for any restarts! (now that we know a '.' + 2 spaces is squeezed to one) (everything's perfectly justified, but it's just luck) Reference(s): http://www.freelists.org/post/procps/top-regression-reports Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
19
top/top.h
19
top/top.h
@ -36,9 +36,10 @@
|
||||
//#define INSP_OFFDEMO /* disable demo screens, issue msg instead */
|
||||
//#define INSP_SAVEBUF /* preserve 'Insp_buf' contents in a file */
|
||||
//#define INSP_SLIDE_1 /* when scrolling left/right don't move 8 */
|
||||
//#define NOBOOST_MEMS /* disable extra precision for mem fields */
|
||||
//#define NOBOOST_PCNT /* disable extra precision for % fields */
|
||||
//#define OFF_HST_HASH /* use BOTH qsort+bsrch vs. hashing scheme */
|
||||
//#define OFF_STDIOLBF /* disable our own stdout _IOFBF override */
|
||||
//#define PERCENTBOOST /* enable extended precision for % fields */
|
||||
//#define PRETEND2_5_X /* pretend we're linux 2.5.x (for IO-wait) */
|
||||
//#define PRETEND4CPUS /* pretend we're smp with 4 ticsers (sic) */
|
||||
//#define PRETENDNOCAP /* use a terminal without essential caps */
|
||||
@ -191,10 +192,9 @@ enum pflag {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* The scaling 'type' used with scale_unum() -- this is how
|
||||
the passed number is interpreted should scaling be necessary */
|
||||
enum scale_unum {
|
||||
SK_no, SK_Kb, SK_Mb, SK_Gb, SK_Tb
|
||||
/* The scaling 'target' used with memory fields */
|
||||
enum scale_enum {
|
||||
SK_Kb, SK_Mb, SK_Gb, SK_Tb, SK_SENTINEL
|
||||
};
|
||||
|
||||
/* This typedef just ensures consistent 'process flags' handling */
|
||||
@ -211,7 +211,7 @@ typedef int (*QFP_t)(const void *, const void *);
|
||||
in a variety of display roles. */
|
||||
typedef struct FLD_t {
|
||||
int width; // field width, if applicable
|
||||
const int scale; // scale_unum type, if applicable
|
||||
int scale; // scaled target, if applicable
|
||||
const int align; // the default column alignment flag
|
||||
const QFP_t sort; // sort function
|
||||
const int lflg; // PROC_FILLxxx flag(s) needed by this field
|
||||
@ -337,6 +337,8 @@ typedef struct RCF_t {
|
||||
RCW_t win [GROUPSMAX]; // a 'WIN_t.rc' for each window
|
||||
int fixed_widest; // 'X' - wider non-scalable col addition
|
||||
int summ_mscale; // 'E' - scaling of summary memory values
|
||||
int task_mscale; // 'e' - scaling of process memory values
|
||||
int zero_suppress; // '0' - suppress scaled zeros toggle
|
||||
} RCF_t;
|
||||
|
||||
/* This structure stores configurable information for each window.
|
||||
@ -635,9 +637,10 @@ typedef struct WIN_t {
|
||||
//atic inline const char *make_chr (const char ch, int width, int justr);
|
||||
//atic inline const char *make_num (long num, int width, int justr, int col);
|
||||
//atic inline const char *make_str (const char *str, int width, int justr, int col);
|
||||
//atic inline const char *scale_pcnt (float num, int width, int justr);
|
||||
//atic const char *scale_mem (int target, unsigned long num, int width, int justr);
|
||||
//atic const char *scale_num (unsigned long num, int width, int justr);
|
||||
//atic const char *scale_pcnt (float num, int width, int justr);
|
||||
//atic const char *scale_tics (TIC_t tics, int width, int justr);
|
||||
//atic const char *scale_unum (unsigned long num, int type, int width, int justr);
|
||||
/*------ Fields Management support -------------------------------------*/
|
||||
/*atic FLD_t Fieldstab[] = { ... } */
|
||||
//atic void adj_geometry (void);
|
||||
|
Reference in New Issue
Block a user