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,47 +149,45 @@ local tbl = _G_Widget_.Table{
|
||||||
}
|
}
|
||||||
|
|
||||||
local update = function(cr)
|
local update = function(cr)
|
||||||
-- see source for the 'free' command (sysinfo.c) for formulas
|
local conky = Util.conky
|
||||||
|
-- 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,
|
||||||
slab_reclaimable_kb = __string_match(Util.read_file('/proc/meminfo'), MEMINFO_REGEX)
|
slab_reclaimable_kb = __string_match(Util.read_file('/proc/meminfo'), MEMINFO_REGEX)
|
||||||
|
|
||||||
local used_percent = (MEM_TOTAL_KB - memfree_kb - cached_kb - buffers_kb - slab_reclaimable_kb) / MEM_TOTAL_KB
|
local used_percent = (MEM_TOTAL_KB - memfree_kb - cached_kb - buffers_kb - slab_reclaimable_kb) / MEM_TOTAL_KB
|
||||||
|
|
||||||
Dial.set(dial, used_percent)
|
Dial.set(dial, used_percent)
|
||||||
CriticalText.set(total_used, cr, Util.round_to_string(used_percent * 100))
|
CriticalText.set(total_used, cr, Util.round_to_string(used_percent * 100))
|
||||||
|
|
||||||
local cache_theta = (DIAL_THETA_0 - DIAL_THETA_1) / MEM_TOTAL_KB * memfree_kb + DIAL_THETA_1
|
local cache_theta = (DIAL_THETA_0 - DIAL_THETA_1) / MEM_TOTAL_KB * memfree_kb + DIAL_THETA_1
|
||||||
__cairo_path_destroy(cache_arc.path)
|
__cairo_path_destroy(cache_arc.path)
|
||||||
cache_arc.path = Arc.create_path(cr, DIAL_X, DIAL_Y, DIAL_RADIUS, dial.dial_angle, cache_theta)
|
cache_arc.path = Arc.create_path(cr, DIAL_X, DIAL_Y, DIAL_RADIUS, dial.dial_angle, cache_theta)
|
||||||
|
|
||||||
CriticalText.set(swap.percent, cr, Util.precision_round_to_string(
|
CriticalText.set(swap.percent, cr, Util.precision_round_to_string(
|
||||||
(swap_total_kb - swap_free_kb) / swap_total_kb * 100))
|
(swap_total_kb - swap_free_kb) / swap_total_kb * 100))
|
||||||
|
|
||||||
local _percents = cache.percents
|
local _percents = cache.percents
|
||||||
|
|
||||||
TextColumn.set(_percents, cr, 1, Util.precision_round_to_string(
|
TextColumn.set(_percents, cr, 1, Util.precision_round_to_string(
|
||||||
cached_kb / MEM_TOTAL_KB * 100))
|
cached_kb / MEM_TOTAL_KB * 100))
|
||||||
|
|
||||||
TextColumn.set(_percents, cr, 2, Util.precision_round_to_string(
|
TextColumn.set(_percents, cr, 2, Util.precision_round_to_string(
|
||||||
buffers_kb / MEM_TOTAL_KB * 100))
|
buffers_kb / MEM_TOTAL_KB * 100))
|
||||||
|
|
||||||
TextColumn.set(_percents, cr, 3, Util.precision_round_to_string(
|
TextColumn.set(_percents, cr, 3, Util.precision_round_to_string(
|
||||||
slab_reclaimable_kb / MEM_TOTAL_KB * 100))
|
slab_reclaimable_kb / MEM_TOTAL_KB * 100))
|
||||||
|
|
||||||
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
|
||||||
|
local comm = conky(TABLE_CONKY[r].comm, '(%S+)') -- may have trailing space
|
||||||
for r = 1, NUM_ROWS do
|
local pid = conky(TABLE_CONKY[r].pid)
|
||||||
local ps_line = ps_glob:read()
|
local mem = conky(TABLE_CONKY[r].mem)
|
||||||
local pmem, pid, comm = __string_match(ps_line, '(%d+%.%d+)%s+(%d+)%s+(.+)$')
|
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, mem)
|
||||||
Table.set(tbl, cr, 3, r, pmem)
|
end
|
||||||
end
|
|
||||||
|
|
||||||
ps_glob:close()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
_MODULE_Y_ = nil
|
_MODULE_Y_ = nil
|
||||||
|
|
Loading…
Reference in New Issue