ENH reduce memory table power consumption
This commit is contained in:
parent
d1221a4ae9
commit
6fa19db996
|
@ -36,6 +36,15 @@ local MEMINFO_REGEX = '\nMemFree:%s+(%d+).+'..
|
||||||
|
|
||||||
local NUM_ROWS = 5
|
local NUM_ROWS = 5
|
||||||
|
|
||||||
|
local TABLE_CONKY = {}
|
||||||
|
|
||||||
|
for r = 1, NUM_ROWS do
|
||||||
|
TABLE_CONKY[r] = {}
|
||||||
|
TABLE_CONKY[r].comm = '${top_mem name '..r..'}'
|
||||||
|
TABLE_CONKY[r].pid = '${top_mem pid '..r..'}'
|
||||||
|
TABLE_CONKY[r].mem = '${top_mem mem '..r..'}'
|
||||||
|
end
|
||||||
|
|
||||||
local header = _G_Widget_.Header{
|
local header = _G_Widget_.Header{
|
||||||
x = _G_INIT_DATA_.RIGHT_X,
|
x = _G_INIT_DATA_.RIGHT_X,
|
||||||
y = _MODULE_Y_,
|
y = _MODULE_Y_,
|
||||||
|
@ -140,6 +149,7 @@ local tbl = _G_Widget_.Table{
|
||||||
}
|
}
|
||||||
|
|
||||||
local update = function(cr)
|
local update = function(cr)
|
||||||
|
local conky = Util.conky
|
||||||
-- see source for the 'free' command (sysinfo.c) for formulas
|
-- see source for the 'free' command (sysinfo.c) for formulas
|
||||||
|
|
||||||
local memfree_kb, buffers_kb, cached_kb, swap_total_kb, swap_free_kb,
|
local memfree_kb, buffers_kb, cached_kb, swap_total_kb, swap_free_kb,
|
||||||
|
@ -170,17 +180,14 @@ local update = function(cr)
|
||||||
|
|
||||||
LabelPlot.update(plot, used_percent)
|
LabelPlot.update(plot, used_percent)
|
||||||
|
|
||||||
local ps_glob = __io_popen('ps -A -o "pmem,pid,comm" --sort=-pmem h')
|
|
||||||
|
|
||||||
for r = 1, NUM_ROWS do
|
for r = 1, NUM_ROWS do
|
||||||
local ps_line = ps_glob:read()
|
local comm = conky(TABLE_CONKY[r].comm, '(%S+)') -- may have trailing space
|
||||||
local pmem, pid, comm = __string_match(ps_line, '(%d+%.%d+)%s+(%d+)%s+(.+)$')
|
local pid = conky(TABLE_CONKY[r].pid)
|
||||||
|
local mem = conky(TABLE_CONKY[r].mem)
|
||||||
Table.set(tbl, cr, 1, r, comm)
|
Table.set(tbl, cr, 1, r, comm)
|
||||||
Table.set(tbl, cr, 2, r, pid)
|
Table.set(tbl, cr, 2, r, pid)
|
||||||
Table.set(tbl, cr, 3, r, pmem)
|
Table.set(tbl, cr, 3, r, mem)
|
||||||
end
|
end
|
||||||
|
|
||||||
ps_glob:close()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
_MODULE_Y_ = nil
|
_MODULE_Y_ = nil
|
||||||
|
|
Loading…
Reference in New Issue