small speedup for top table

This commit is contained in:
petrucci4prez 2018-08-04 17:54:34 -04:00
parent 23cd57d1aa
commit 0872cc236c
1 changed files with 14 additions and 10 deletions

View File

@ -13,12 +13,13 @@ local NUM_PHYSICAL_CORES = 4
local NUM_THREADS_PER_CORE = 2 local NUM_THREADS_PER_CORE = 2
local NUM_ROWS = 5 local NUM_ROWS = 5
local TABLE_CONKY = {{}, {}, {}}
local TABLE_CONKY = {}
for r = 1, NUM_ROWS do for r = 1, NUM_ROWS do
TABLE_CONKY[1][r] = '${top name '..r..'}' TABLE_CONKY[r] = {}
TABLE_CONKY[2][r] = '${top pid '..r..'}' TABLE_CONKY[r].pid = '${top pid '..r..'}'
TABLE_CONKY[3][r] = '${top cpu '..r..'}' TABLE_CONKY[r].cpu = '${top cpu '..r..'}'
end end
local _MODULE_Y_ = 614 local _MODULE_Y_ = 614
@ -187,7 +188,6 @@ local update = function(cr)
for c = 1, NUM_PHYSICAL_CORES do for c = 1, NUM_PHYSICAL_CORES do
local core = cores[c] local core = cores[c]
local conky_loads = core.conky_loads local conky_loads = core.conky_loads
local conky_freqs = core.conky_freqs local conky_freqs = core.conky_freqs
@ -218,11 +218,15 @@ local update = function(cr)
LabelPlot.update(plot, load_percent) LabelPlot.update(plot, load_percent)
for c = 1, 3 do for r = 1, NUM_ROWS do
local column = TABLE_CONKY[c] local pid = conky(TABLE_CONKY[r].pid, '(%S+)')
for r = 1, NUM_ROWS do if pid ~= '' then
Table.set(tbl, cr, c, r, conky(column[r], '(%S+)')) local cpu = conky(TABLE_CONKY[r].cpu)
end local comm = Util.read_file('/proc/'..pid..'/stat', '%d+%s+%((.+)%)')
Table.set(tbl, cr, 1, r, comm)
Table.set(tbl, cr, 2, r, pid)
Table.set(tbl, cr, 3, r, cpu)
end
end end
end end