Skip to content

Commit

Permalink
add command to see module overall with command (eprofiler all)
Browse files Browse the repository at this point in the history
  • Loading branch information
kodewdle committed Nov 13, 2024
1 parent 4f6b54f commit 7004772
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions ElvUI/Core/General/Commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ do
local list = {}
local text = ''

function E:BuildProfilerText(tbl, data)
function E:BuildProfilerText(tbl, data, overall)
for _, info in ipairs(tbl) do
if info.key == '_module' then
local all = E.profiler.data._all
Expand All @@ -87,7 +87,7 @@ do
local percent = (total / all.total) * 100
text = format('%s%s > count: %d | total: %0.2fms (addon %0.2f%%)\n', text, info.module or '', info.count or 0, total, percent)
end
else
elseif not overall then
local total = info.total or 0
local modulePercent = (total / data._module.total) * 100

Expand All @@ -100,7 +100,9 @@ do
end
end

text = format('%s\n', text)
if not overall then
text = format('%s\n', text)
end

wipe(temp)
wipe(list)
Expand All @@ -118,7 +120,7 @@ do
return self.total > second.total
end

function E:SortProfilerData(module, data)
function E:SortProfilerData(module, data, overall)
for key, value in next, data do
local info = CopyTable(value)
info.module = module
Expand All @@ -129,7 +131,7 @@ do

sort(temp, E.ProfilerSort)

E:BuildProfilerText(temp, data)
E:BuildProfilerText(temp, data, overall)
end

function E:ShowProfilerText()
Expand Down Expand Up @@ -160,13 +162,29 @@ do
end
end

local function FetchAll(overall)
local data = E.profiler.data[E]
if data then
E:SortProfilerData('E', data, overall)
end

for key, module in next, E.modules do
local info = E.profiler.data[module]
if info then
E:SortProfilerData(key, info, overall)
end
end
end

function E:FetchProfilerData(msg)
local switch = lower(msg)
if switch ~= '' then
if switch == 'reset' then
E.profiler.reset()

return E:Print('Reset profiler.')
elseif switch == 'all' then
FetchAll(true)
elseif switch == 'e' then
local data = E.profiler.data[E]
if data then
Expand All @@ -183,17 +201,7 @@ do
end
end
else
local data = E.profiler.data[E]
if data then
E:SortProfilerData('E', data)
end

for key, module in next, E.modules do
local info = E.profiler.data[module]
if info then
E:SortProfilerData(key, info)
end
end
FetchAll()
end

E:ShowProfilerText()
Expand Down

0 comments on commit 7004772

Please sign in to comment.