From 77abe18d0150fa162fcf399eb52c7521501ba789 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Tue, 14 May 2013 00:00:00 -0500 Subject: [PATCH] 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 21e550bc080eb30f503b2ca6fe4e9cb12b8a1616 Signed-off-by: Jim Warner --- configure.ac | 8 ++++++++ top/top.c | 6 +++--- top/top.h | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 19a8f260..08474b1b 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) 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= AC_ARG_ENABLE([numa], AS_HELP_STRING([--disable-numa], [disable NUMA/Node support in top]), diff --git a/top/top.c b/top/top.c index 042e5fe7..4caf6580 100644 --- a/top/top.c +++ b/top/top.c @@ -1564,7 +1564,7 @@ static const char *scale_pcnt (float num, int width, int justr) { buf[0] = '\0'; if (Rc.zero_suppress && 0 >= num) goto end_justifies; -#ifndef NOBOOST_PCNT +#ifdef BOOST_PERCNT if (width >= snprintf(buf, sizeof(buf), "%#.3f", num)) goto end_justifies; if (width >= snprintf(buf, sizeof(buf), "%#.2f", num)) @@ -1699,7 +1699,7 @@ static FLD_t Fieldstab[] = { { 0, -1, A_right, SF(CPU), L_stat }, { 6, -1, A_right, SF(TME), L_stat }, { 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 #else { 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; } -#ifndef NOBOOST_PCNT +#ifdef BOOST_PERCNT Cpu_pmax = 99.9; Fieldstab[P_CPU].width = 5; if (Rc.mode_irixps && smp_num_cpus > 1 && !Thread_mode) { diff --git a/top/top.h b/top/top.h index 01434ed0..f327cfdb 100644 --- a/top/top.h +++ b/top/top.h @@ -23,6 +23,7 @@ #include "../proc/readproc.h" /* Defines represented in configure.ac ----------------------------- */ +//#define BOOST_PERCNT /* enable extra precision for two % fields */ //#define NUMA_DISABLE /* disable summary area NUMA/Nodes display */ //#define OOMEM_ENABLE /* enable the SuSE out-of-memory additions */ //#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_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 PRETEND2_5_X /* pretend we're linux 2.5.x (for IO-wait) */