top: avoid yet more overhead of accessing /proc/status

After discovering those terrible costs associated with
/proc/status vs. /proc/stat, our library changed so as
to favor the latter if a field could be met by either.

Well, low-and-behold, this top program had chosen some
item enumerators that needlessly caused 'status' to be
accessed when 'statm' could be used instead. And while
top's needs require conversion from pages to KiB, that
is still far less costly than that damn 'status' file.

[ this was found when comparing newlib top against a ]
[ 3.2.8 ancient top since the current master top was ]
[ suffering from the exact same 'status' deficiency. ]

[ and, no way was top-3.2.8 going to beat newlib top ]
[ by 50% - we'll allow only a 1-10% occasional loss! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2016-08-21 00:00:00 -05:00 committed by Craig Small
parent 3ac040d047
commit b53fb7f8ea

View File

@ -1519,21 +1519,21 @@ static struct {
{ 6, -1, A_right, -1, PIDS_TICS_ALL }, // ull_int EU_TME
{ 9, -1, A_right, -1, PIDS_TICS_ALL }, // ull_int EU_TM2
#ifdef BOOST_PERCNT
{ 5, -1, A_right, -1, PIDS_VM_RSS }, // ul_int EU_MEM
{ 5, -1, A_right, -1, PIDS_MEM_RES }, // ul_int EU_MEM
#else
{ 4, -1, A_right, -1, PIDS_VM_RSS }, // ul_int EU_MEM,
{ 4, -1, A_right, -1, PIDS_MEM_RES }, // ul_int EU_MEM,
#endif
#ifndef NOBOOST_MEMS
{ 7, SK_Kb, A_right, -1, PIDS_MEM_VIRT }, // ul_int EU_VRT
{ 6, SK_Kb, A_right, -1, PIDS_VM_SWAP }, // ul_int EU_SWP
{ 6, SK_Kb, A_right, -1, PIDS_VM_RSS }, // ul_int EU_RES
{ 6, SK_Kb, A_right, -1, PIDS_MEM_RES }, // ul_int EU_RES
{ 6, SK_Kb, A_right, -1, PIDS_MEM_CODE }, // ul_int EU_COD
{ 7, SK_Kb, A_right, -1, PIDS_MEM_DATA }, // ul_int EU_DAT
{ 6, SK_Kb, A_right, -1, PIDS_MEM_SHR }, // ul_int EU_SHR
#else
{ 5, SK_Kb, A_right, -1, PIDS_MEM_VIRT }, // ul_int EU_VRT
{ 4, SK_Kb, A_right, -1, PIDS_VM_SWAP }, // ul_int EU_SWP
{ 4, SK_Kb, A_right, -1, PIDS_VM_RSS }, // ul_int EU_RES
{ 4, SK_Kb, A_right, -1, PIDS_MEM_RES }, // ul_int EU_RES
{ 4, SK_Kb, A_right, -1, PIDS_MEM_CODE }, // ul_int EU_COD
{ 5, SK_Kb, A_right, -1, PIDS_MEM_DATA }, // ul_int EU_DAT
{ 4, SK_Kb, A_right, -1, PIDS_MEM_SHR }, // ul_int EU_SHR