top: revert %CPU and %MEM precision to former defaults

When summary & task area memory scaling was introduced
in release 3.3.6, the percentage columns were expanded
to provide 3 decimal places of precision. In hindsight
that may have been overkill, making those columns more
of a distraction than useful, with just too much info.

This patch will revert those columns to the former one
decimal place. And as was true, that decimal point may
be sacrificed depending on the number of cpus present.

And, in case anyone might prefer additional precision,
a build option can provide it (--enable-wide-percent).

Reference(s):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=707648
http://www.freelists.org/post/procps/What-happened-to-my-top,1
commit 21e550bc08

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2013-05-14 00:00:00 -05:00 committed by Craig Small
parent 3993fb0c8e
commit 77abe18d01
3 changed files with 12 additions and 4 deletions

View File

@ -195,6 +195,14 @@ if test "x$enable_sigwinch" = xyes; then
AC_DEFINE(SIGNALS_LESS, 1, [reduce impact of x-windows resize operations on top]) AC_DEFINE(SIGNALS_LESS, 1, [reduce impact of x-windows resize operations on top])
fi fi
AC_ARG_ENABLE([wide-percent],
AS_HELP_STRING([--enable-wide-percent], [provide extra precision under %CPU and %MEM for top]),
[enable_wide_percent=yes], []
)
if test "x$enable_wide_percent" = xyes; then
AC_DEFINE(BOOST_PERCNT, 1, [provide extra precision under %CPU and %MEM for top])
fi
DL_LIB= DL_LIB=
AC_ARG_ENABLE([numa], AC_ARG_ENABLE([numa],
AS_HELP_STRING([--disable-numa], [disable NUMA/Node support in top]), AS_HELP_STRING([--disable-numa], [disable NUMA/Node support in top]),

View File

@ -1564,7 +1564,7 @@ static const char *scale_pcnt (float num, int width, int justr) {
buf[0] = '\0'; buf[0] = '\0';
if (Rc.zero_suppress && 0 >= num) if (Rc.zero_suppress && 0 >= num)
goto end_justifies; goto end_justifies;
#ifndef NOBOOST_PCNT #ifdef BOOST_PERCNT
if (width >= snprintf(buf, sizeof(buf), "%#.3f", num)) if (width >= snprintf(buf, sizeof(buf), "%#.3f", num))
goto end_justifies; goto end_justifies;
if (width >= snprintf(buf, sizeof(buf), "%#.2f", num)) if (width >= snprintf(buf, sizeof(buf), "%#.2f", num))
@ -1699,7 +1699,7 @@ static FLD_t Fieldstab[] = {
{ 0, -1, A_right, SF(CPU), L_stat }, { 0, -1, A_right, SF(CPU), L_stat },
{ 6, -1, A_right, SF(TME), L_stat }, { 6, -1, A_right, SF(TME), L_stat },
{ 9, -1, A_right, SF(TME), L_stat }, // P_TM2 slot { 9, -1, A_right, SF(TME), L_stat }, // P_TM2 slot
#ifndef NOBOOST_PCNT #ifdef BOOST_PERCNT
{ 5, -1, A_right, SF(RES), L_statm }, // P_MEM slot { 5, -1, A_right, SF(RES), L_statm }, // P_MEM slot
#else #else
{ 4, -1, A_right, SF(RES), L_statm }, // P_MEM slot { 4, -1, A_right, SF(RES), L_statm }, // P_MEM slot
@ -2238,7 +2238,7 @@ static void zap_fieldstab (void) {
Fieldstab[P_CPN].width = digits; Fieldstab[P_CPN].width = digits;
} }
#ifndef NOBOOST_PCNT #ifdef BOOST_PERCNT
Cpu_pmax = 99.9; Cpu_pmax = 99.9;
Fieldstab[P_CPU].width = 5; Fieldstab[P_CPU].width = 5;
if (Rc.mode_irixps && smp_num_cpus > 1 && !Thread_mode) { if (Rc.mode_irixps && smp_num_cpus > 1 && !Thread_mode) {

View File

@ -23,6 +23,7 @@
#include "../proc/readproc.h" #include "../proc/readproc.h"
/* Defines represented in configure.ac ----------------------------- */ /* Defines represented in configure.ac ----------------------------- */
//#define BOOST_PERCNT /* enable extra precision for two % fields */
//#define NUMA_DISABLE /* disable summary area NUMA/Nodes display */ //#define NUMA_DISABLE /* disable summary area NUMA/Nodes display */
//#define OOMEM_ENABLE /* enable the SuSE out-of-memory additions */ //#define OOMEM_ENABLE /* enable the SuSE out-of-memory additions */
//#define SIGNALS_LESS /* favor reduced signal load over response */ //#define SIGNALS_LESS /* favor reduced signal load over response */
@ -39,7 +40,6 @@
//#define INSP_SAVEBUF /* preserve 'Insp_buf' contents in a file */ //#define INSP_SAVEBUF /* preserve 'Insp_buf' contents in a file */
//#define INSP_SLIDE_1 /* when scrolling left/right don't move 8 */ //#define INSP_SLIDE_1 /* when scrolling left/right don't move 8 */
//#define NOBOOST_MEMS /* disable extra precision for mem fields */ //#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_HST_HASH /* use BOTH qsort+bsrch vs. hashing scheme */
//#define OFF_STDIOLBF /* disable our own stdout _IOFBF override */ //#define OFF_STDIOLBF /* disable our own stdout _IOFBF override */
//#define PRETEND2_5_X /* pretend we're linux 2.5.x (for IO-wait) */ //#define PRETEND2_5_X /* pretend we're linux 2.5.x (for IO-wait) */