top: make '#define GRAPHS_ALIGN' an immutable solution
My original graph modes implementation made no attempt to align the Cpu & Mem/Swap graphs. I thought, rather, that such alignment could be best achieved by the user using top's 'E' memory scaling command toggle. In that way Mem/Swap prefixes could be reduced by 3 positions, bringing the beginning '[' into line with the %Cpu(s). If that proved to be too cumbersome a #define could be enabled making the Mem/Swap prefix static while adding a few padding bytes to the %Cpu line(s) for alignment. It was those waisted bytes that were the most concern. What I had not counted on was the fact that the memory lines themselves might become misaligned & that became likely with more physical memory present. That too can be cured with the 'E' command but as scaling is raised we soon reach a meaningless total such as '0.003' even though the displayed % remains valid (and unchanging). So this commit implements unconditionally what used to be conditional. But, instead of waisting padding bytes we'll put that space to good use with a new 'total %'. Reference(s): http://www.freelists.org/post/procps/latest-top-enhancements,1 commit 1d171ec74163f3103e7b230ee63818df04b4526f Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
f33d49c6cf
commit
b8614adcb5
14
top/top.c
14
top/top.c
@ -5070,12 +5070,8 @@ static void summary_hlp (CPU_t *cpu, const char *pfx) {
|
||||
snprintf(user, sizeof(user), gtab[ix].user, (int)(pct_user + .5), gtab[ix].type);
|
||||
snprintf(syst, sizeof(syst), gtab[ix].syst, (int)(pct_syst + .5), gtab[ix].type);
|
||||
snprintf(dual, sizeof(dual), "%s%s", user, syst);
|
||||
#ifdef GRAPHS_ALIGN
|
||||
show_special(0, fmtmk("%%%s ~3%#5.1f~2/%-#8.1f~3 [~1%-104.104s]~1\n"
|
||||
#else
|
||||
show_special(0, fmtmk("%%%s ~3%#5.1f~2/%-#5.1f~3 [~1%-104.104s]~1\n"
|
||||
#endif
|
||||
, pfx, pct_user, pct_syst, dual));
|
||||
show_special(0, fmtmk("%%%s ~3%#5.1f~2/%-#5.1f~3 %3.0f[~1%-104.104s]~1\n"
|
||||
, pfx, pct_user, pct_syst, pct_user + pct_syst, dual));
|
||||
} else {
|
||||
show_special(0, fmtmk(Cpu_States_fmts, pfx
|
||||
, (float)u_frme * scale, (float)s_frme * scale
|
||||
@ -5229,13 +5225,7 @@ numa_nope:
|
||||
snprintf(util, sizeof(util), gtab[ix].swap, (int)(pct_swap + .5), gtab[ix].type);
|
||||
prT(bfT(0), mkM(total)); prT(bfT(1), mkS(total));
|
||||
show_special(0, fmtmk(
|
||||
#ifdef GRAPHS_ALIGN
|
||||
/* note: without this define, cpu and memory graphs can usually be aligned via scaling
|
||||
(the 'E' command) and without any waisted space preceeding the cpu graphs */
|
||||
"%s %s:~3%#5.1f~2/%-9.9s~3[~1%-104.104s]~1\n%s %s:~3%#5.1f~2/%-9.9s~3[~1%-102.102s]~1\n"
|
||||
#else
|
||||
"%s %s:~3%#5.1f~2/%-.9s~3[~1%-104.104s]~1\n%s %s:~3%#5.1f~2/%-.9s~3[~1%-102.102s]~1\n"
|
||||
#endif
|
||||
, scT(label), N_txt(WORD_abv_mem_txt), pct_used + pct_misc, bfT(0), dual
|
||||
, scT(label), N_txt(WORD_abv_swp_txt), pct_swap, bfT(1), util));
|
||||
} else {
|
||||
|
@ -36,7 +36,6 @@
|
||||
//#define CASEUP_SUFIX /* show time/mem/cnts suffix in upper case */
|
||||
//#define CPU_ZEROTICS /* tolerate few tics when cpu off vs. idle */
|
||||
//#define EQUCOLHDRYES /* yes, do equalize column header lengths */
|
||||
//#define GRAPHS_ALIGN /* force cpu & memory graphs to be aligned */
|
||||
//#define INSP_JUSTNOT /* don't smooth unprintable right margins */
|
||||
//#define INSP_OFFDEMO /* disable demo screens, issue msg instead */
|
||||
//#define INSP_SAVEBUF /* preserve 'Insp_buf' contents in a file */
|
||||
|
Loading…
x
Reference in New Issue
Block a user