top: extend scaled process memory range to include PiB
The recent change to task area memory scaling was just a little short of optimum in its consistency and upper limits. In fact, top could only scale memory fields up to a maximum of 99.9999 TiB (with VIRT a little more). While that seems like more than enough it was actually artificially low, due to an unnecessary decimal place. So, this commit standardizes both precision and widths to achieve a minimum amount of scaling beyond the user requested target plus reclaim some horizontal spacing. . VIRT & DATA are now 7 bytes wide (not eight and six) . other memory fields are 6 wide (were formerly seven) . as before, KiB shows whole numbers only (no decimal) . MiB, for its precision, shows a single decimal place . all other memory ranges display three decimal places The net result is a more homogeneous display with less forced scaling and the recovery of three lost columns. (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-enhancements-i-hope,1 Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
e6cb40235e
commit
2e7adced74
@ -857,7 +857,7 @@ depending on the context in which they are issued.
|
||||
.Bd -literal
|
||||
4a.\fI Global-Commands \fR
|
||||
<Ent/Sp> ?, =, 0,
|
||||
A, B, d, E, g, h, H, I, k, q, r, s, W, X, Y, Z
|
||||
A, B, d, E, e, g, h, H, I, k, q, r, s, W, X, Y, Z
|
||||
4b.\fI Summary-Area-Commands \fR
|
||||
C, l, t, 1, m
|
||||
4c.\fI Task-Area-Commands \fR
|
||||
@ -971,13 +971,15 @@ By raising the scaling factor, such truncation can be avoided.
|
||||
.TP 7
|
||||
\ \ \'\fBe\fR\' :\fIExtend-Memory-Scale\fR in Task Windows
|
||||
With this command you can cycle through the available \*(TW memory scaling
|
||||
which ranges from KiB (kibibytes or 1,024 bytes) through TiB (tebibytes or
|
||||
1,099,511,627,776 bytes).
|
||||
which ranges from KiB (kibibytes or 1,024 bytes) through PiB (pebibytes or
|
||||
1,125,899,906,842,624 bytes).
|
||||
|
||||
While \*(We will try to honor the selected target range, additional
|
||||
scaling might still be necessary in order to accommodate current values.
|
||||
If you wish to see a more homogeneous result in the memory columns,
|
||||
raising the scaling range will usually accomplish that goal.
|
||||
Raising it too high, however, is likely to produce an all zero result
|
||||
which cannot be suppressed with the '0' \*(CI.
|
||||
|
||||
.TP 7
|
||||
\ \ \'\fBg\fR\' :\fIChoose-Another-Window/Field-Group \fR
|
||||
|
27
top/top.c
27
top/top.c
@ -201,9 +201,9 @@ static int Autox_array [P_MAXPFLGS],
|
||||
|
||||
/* Support for scale_mem and scale_num (to avoid duplication. */
|
||||
#ifdef CASEUP_SUFIX
|
||||
static char Scaled_sfxtab[] = { 'K', 'M', 'G', 'T', 0 };
|
||||
static char Scaled_sfxtab[] = { 'K', 'M', 'G', 'T', 'P', 'E', 0 };
|
||||
#else
|
||||
static char Scaled_sfxtab[] = { 'k', 'm', 'g', 't', 0 };
|
||||
static char Scaled_sfxtab[] = { 'k', 'm', 'g', 't', 'p', 'e', 0 };
|
||||
#endif
|
||||
|
||||
/*###### Sort callbacks ################################################*/
|
||||
@ -1272,9 +1272,10 @@ static inline const char *make_str (const char *str, int width, int justr, int c
|
||||
* format it to reach 'target' while also fitting 'width'. */
|
||||
static const char *scale_mem (int target, unsigned long num, int width, int justr) {
|
||||
#ifndef NOBOOST_MEMS
|
||||
static const char *fmttab[] = { "%.0f", "%#.2f%c", "%#.3f%c", "%#.4f%c", NULL };
|
||||
// SK_Kb SK_Mb SK_Gb SK_Tb SK_Pb SK_Eb
|
||||
static const char *fmttab[] = { "%.0f", "%#.1f%c", "%#.3f%c", "%#.3f%c", "%#.3f%c", NULL };
|
||||
#else
|
||||
static const char *fmttab[] = { "%.0f", "%.0f%c", "%.0f%c", "%.0f%c", NULL };
|
||||
static const char *fmttab[] = { "%.0f", "%.0f%c", "%.0f%c", "%.0f%c", "%.0f%c", NULL };
|
||||
#endif
|
||||
static char buf[SMLBUFSIZ];
|
||||
float scaled_num;
|
||||
@ -1286,7 +1287,7 @@ static const char *scale_mem (int target, unsigned long num, int width, int just
|
||||
goto end_justifies;
|
||||
|
||||
scaled_num = num;
|
||||
for (i = 0, psfx = Scaled_sfxtab; 0 < *psfx; psfx++, i++) {
|
||||
for (i = SK_Kb, psfx = Scaled_sfxtab; i < SK_Eb; psfx++, i++) {
|
||||
if (i >= target
|
||||
&& (width >= snprintf(buf, sizeof(buf), fmttab[i], scaled_num, *psfx)))
|
||||
goto end_justifies;
|
||||
@ -1477,18 +1478,18 @@ static FLD_t Fieldstab[] = {
|
||||
{ 4, -1, A_right, SF(RES), L_statm }, // P_MEM slot
|
||||
#endif
|
||||
#ifndef NOBOOST_MEMS
|
||||
{ 8, SK_Kb, A_right, SF(VRT), L_statm },
|
||||
{ 7, SK_Kb, A_right, SF(SWP), L_status },
|
||||
{ 7, SK_Kb, A_right, SF(RES), L_statm },
|
||||
{ 7, SK_Kb, A_right, SF(COD), L_statm },
|
||||
{ 7, SK_Kb, A_right, SF(VRT), L_statm },
|
||||
{ 6, SK_Kb, A_right, SF(SWP), L_status },
|
||||
{ 6, SK_Kb, A_right, SF(RES), L_statm },
|
||||
{ 6, SK_Kb, A_right, SF(COD), L_statm },
|
||||
{ 7, SK_Kb, A_right, SF(DAT), L_statm },
|
||||
{ 7, SK_Kb, A_right, SF(SHR), L_statm },
|
||||
{ 6, SK_Kb, A_right, SF(SHR), L_statm },
|
||||
#else
|
||||
{ 5, SK_Kb, A_right, SF(VRT), L_statm },
|
||||
{ 4, SK_Kb, A_right, SF(SWP), L_status },
|
||||
{ 4, SK_Kb, A_right, SF(RES), L_statm },
|
||||
{ 4, SK_Kb, A_right, SF(COD), L_statm },
|
||||
{ 4, SK_Kb, A_right, SF(DAT), L_statm },
|
||||
{ 5, SK_Kb, A_right, SF(DAT), L_statm },
|
||||
{ 4, SK_Kb, A_right, SF(SHR), L_statm },
|
||||
#endif
|
||||
{ 4, -1, A_right, SF(FL1), L_stat },
|
||||
@ -3044,7 +3045,7 @@ static int config_cvt (WIN_t *q) {
|
||||
* line a: contains w->winname, fieldscur
|
||||
* line b: contains w->winflags, sortindx, maxtasks
|
||||
* line c: contains w->summclr, msgsclr, headclr, taskclr
|
||||
* line 15 : Fixed_widest */
|
||||
* line 15 : Fixed_widest, Summ_mscale, Task_mscale, Zero_suppress */
|
||||
static void configs_read (void) {
|
||||
float tmp_delay = DEF_DELAY;
|
||||
char fbuf[LRGBUFSIZ];
|
||||
@ -3837,7 +3838,7 @@ static void keys_global (int ch) {
|
||||
if (++Rc.summ_mscale > SK_Eb) Rc.summ_mscale = SK_Kb;
|
||||
break;
|
||||
case 'e':
|
||||
if (++Rc.task_mscale > SK_Tb) Rc.task_mscale = SK_Kb;
|
||||
if (++Rc.task_mscale > SK_Pb) Rc.task_mscale = SK_Kb;
|
||||
break;
|
||||
case 'F':
|
||||
case 'f':
|
||||
|
Loading…
Reference in New Issue
Block a user