Skip to content

Commit

Permalink
add reset function for profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
kodewdle committed Nov 13, 2024
1 parent 1aede93 commit 4f6b54f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion ElvUI/Core/General/Commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ do
function E:FetchProfilerData(msg)
local switch = lower(msg)
if switch ~= '' then
if switch == 'e' then
if switch == 'reset' then
E.profiler.reset()

return E:Print('Reset profiler.')
elseif switch == 'e' then
local data = E.profiler.data[E]
if data then
E:SortProfilerData('E', data)
Expand Down
14 changes: 11 additions & 3 deletions ElvUI/Core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
]]

local _G = _G
local gsub, tinsert, next, type = gsub, tinsert, next, type
local gsub, tinsert, next, type, wipe = gsub, tinsert, next, type, wipe
local tostring, tonumber, strfind, strmatch = tostring, tonumber, strfind, strmatch

local CreateFrame = CreateFrame
Expand All @@ -30,7 +30,7 @@ local SetCVar = C_CVar.SetCVar

-- GLOBALS: ElvCharacterDB, ElvPrivateDB, ElvDB, ElvCharacterData, ElvPrivateData, ElvData

local ProfilerData, Profiler = { _all = { total = 0, count = 0 } }
local ProfilerData, ProfilerReset, Profiler = {}
do -- not finished
local rawset = rawset
local unpack = unpack
Expand Down Expand Up @@ -106,6 +106,14 @@ do -- not finished
end
end

ProfilerReset = function()
wipe(ProfilerData)

ProfilerData._all = { total = 0, count = 0 }
end

ProfilerReset() -- set up the data

Profiler = function(tbl, ...)
-- print('Profiler', tbl)

Expand All @@ -129,7 +137,7 @@ local CallbackHandler = _G.LibStub('CallbackHandler-1.0')

local AddOnName, Engine = ...
local E = Profiler(AceAddon:NewAddon(AddOnName, 'AceConsole-3.0', 'AceEvent-3.0', 'AceTimer-3.0', 'AceHook-3.0'))
E.profiler = {func = Profiler, data = ProfilerData} -- ElvUI_CPU knock off by Simpy
E.profiler = {func = Profiler, data = ProfilerData, reset = ProfilerReset} -- ElvUI_CPU knock off by Simpy
E.DF = {profile = {}, global = {}}; E.privateVars = {profile = {}} -- Defaults
E.Options = {type = 'group', args = {}, childGroups = 'ElvUI_HiddenTree', get = E.noop, name = ''}
E.callbacks = E.callbacks or CallbackHandler:New(E)
Expand Down

0 comments on commit 4f6b54f

Please sign in to comment.