Skip to content

Commit e5f1993

Browse files
committed
profiler on oUF
1 parent 1ce8c01 commit e5f1993

File tree

15 files changed

+515
-725
lines changed

15 files changed

+515
-725
lines changed

ElvUI/Core/General/API.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
local E, L, V, P, G = unpack(ElvUI)
55
local TT = E:GetModule('Tooltip')
66
local LCS = E.Libs.LCS
7+
local ElvUF = E.oUF
78

89
local _G = _G
910
local type, ipairs, pairs, unpack = type, ipairs, pairs, unpack
@@ -70,7 +71,7 @@ local GameMenuButtonAddons = GameMenuButtonAddons
7071
local GameMenuButtonLogout = GameMenuButtonLogout
7172
local GameMenuFrame = GameMenuFrame
7273
local UIErrorsFrame = UIErrorsFrame
73-
-- GLOBALS: ElvDB, ElvUF
74+
-- GLOBALS: ElvDB
7475

7576
local DebuffColors = E.Libs.Dispel:GetDebuffTypeColor()
7677

ElvUI/Core/General/Commands.lua

+96-25
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local AB = E:GetModule('ActionBars')
66
local type, pairs, sort, tonumber = type, pairs, sort, tonumber
77
local lower, wipe, next, print = strlower, wipe, next, print
88
local ipairs, format, tinsert = ipairs, format, tinsert
9+
local strmatch, gsub = strmatch, gsub
910

1011
local CopyTable = CopyTable
1112
local ReloadUI = ReloadUI
@@ -79,19 +80,20 @@ do
7980
local text = ''
8081

8182
function E:BuildProfilerText(tbl, data, overall)
83+
local full = not overall or overall == 2
8284
for _, info in ipairs(tbl) do
8385
if info.key == '_module' then
84-
local all = E.profiler.data._all
86+
local all = E.Profiler.data._all
8587
if all then
8688
local total = info.total or 0
8789
local percent = (total / all.total) * 100
8890
text = format('%s%s > count: %d | total: %0.2fms (addon %0.2f%%)\n', text, info.module or '', info.count or 0, total, percent)
8991
end
90-
elseif not overall then
92+
elseif full then
9193
local total = info.total or 0
9294
local modulePercent = (total / data._module.total) * 100
9395

94-
local all, allPercent = E.profiler.data._all
96+
local all, allPercent = E.Profiler.data._all
9597
if all then
9698
allPercent = (total / all.total) * 100
9799
end
@@ -100,7 +102,7 @@ do
100102
end
101103
end
102104

103-
if not overall then
105+
if full then
104106
text = format('%s\n', text)
105107
end
106108

@@ -145,33 +147,78 @@ do
145147

146148
function E:GetProfilerData(msg)
147149
local switch = lower(msg)
148-
if switch ~= '' then
149-
if switch == 'e' then
150-
local data = E.profiler.data[E]
150+
if switch == '' then return end
151+
152+
local ouf = switch == 'ouf'
153+
if ouf or switch == 'e' then
154+
local data = E.Profiler.data[ouf and E.oUF or E]
155+
if data then
156+
E:Dump(data, true)
157+
end
158+
elseif switch == 'pooler' then
159+
local data = E.Profiler.data[E.oUF.Pooler]
160+
if data then
161+
E:Dump(data, true)
162+
end
163+
elseif strmatch(switch, '^ouf%s+') then
164+
local element = gsub(switch, '^ouf%s+', '')
165+
if element == '' then return end
166+
167+
for key, module in next, E.oUF.elements do
168+
local data = element == lower(key) and E.Profiler.data[module]
151169
if data then
152170
E:Dump(data, true)
153171
end
154-
else
155-
for key, module in next, E.modules do
156-
local data = switch == lower(key) and E.profiler.data[module]
157-
if data then
158-
E:Dump(data, true)
159-
end
172+
end
173+
else
174+
for key, module in next, E.modules do
175+
local data = switch == lower(key) and E.Profiler.data[module]
176+
if data then
177+
E:Dump(data, true)
160178
end
161179
end
162180
end
163181
end
164182

165183
local function FetchAll(overall)
166-
local data = E.profiler.data[E]
167-
if data then
168-
E:SortProfilerData('E', data, overall)
169-
end
184+
if overall == 2 then
185+
local ouf = E.Profiler.data[E.oUF]
186+
if ouf then
187+
E:SortProfilerData('oUF', ouf, overall)
188+
end
189+
190+
local private = E.Profiler.oUF_Private -- this is special
191+
if private then
192+
E:SortProfilerData('oUF.Private', private, overall)
193+
end
170194

171-
for key, module in next, E.modules do
172-
local info = E.profiler.data[module]
173-
if info then
174-
E:SortProfilerData(key, info, overall)
195+
local pooler = E.Profiler.data[E.oUF.Pooler]
196+
if pooler then
197+
E:SortProfilerData('oUF.Pooler', pooler, overall)
198+
end
199+
200+
for key, module in next, E.oUF.elements do
201+
local info = E.Profiler.data[module]
202+
if info then
203+
E:SortProfilerData(key, info, overall)
204+
end
205+
end
206+
else
207+
local data = E.Profiler.data[E]
208+
if data then
209+
E:SortProfilerData('E', data, overall)
210+
end
211+
212+
local ouf = overall and E.Profiler.data[E.oUF]
213+
if ouf then
214+
E:SortProfilerData('oUF', ouf, overall)
215+
end
216+
217+
for key, module in next, E.modules do
218+
local info = E.Profiler.data[module]
219+
if info then
220+
E:SortProfilerData(key, info, overall)
221+
end
175222
end
176223
end
177224
end
@@ -180,19 +227,43 @@ do
180227
local switch = lower(msg)
181228
if switch ~= '' then
182229
if switch == 'reset' then
183-
E.profiler.reset()
230+
E.Profiler.reset()
184231

185232
return E:Print('Reset profiler.')
186233
elseif switch == 'all' then
187-
FetchAll(true)
234+
FetchAll(1)
235+
elseif switch == 'ouf' then
236+
FetchAll(2)
188237
elseif switch == 'e' then
189-
local data = E.profiler.data[E]
238+
local data = E.Profiler.data[E]
190239
if data then
191240
E:SortProfilerData('E', data)
192241
end
242+
elseif switch == 'ouf' then
243+
local data = E.Profiler.data[E.oUF]
244+
if data then
245+
E:SortProfilerData('oUF', data)
246+
end
247+
elseif switch == 'pooler' then
248+
local data = E.Profiler.data[E.oUF.Pooler]
249+
if data then
250+
E:SortProfilerData('oUF.Pooler', data)
251+
end
252+
elseif strmatch(switch, '^ouf%s+') then
253+
local element = gsub(switch, '^ouf%s+', '')
254+
if element ~= '' then
255+
for key, module in next, E.oUF.elements do
256+
local data = element == lower(key) and E.Profiler.data[module]
257+
if data then
258+
E:SortProfilerData(key, data)
259+
260+
break
261+
end
262+
end
263+
end
193264
else
194265
for key, module in next, E.modules do
195-
local data = switch == lower(key) and E.profiler.data[module]
266+
local data = switch == lower(key) and E.Profiler.data[module]
196267
if data then
197268
E:SortProfilerData(key, data)
198269

ElvUI/Core/Modules/DataBars/Threat.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local E, L, V, P, G = unpack(ElvUI)
22
local DB = E:GetModule('DataBars')
3+
local ElvUF = E.oUF
34

45
local next = next
56
local wipe = wipe
@@ -15,7 +16,6 @@ local UnitIsUnit = UnitIsUnit
1516
local UnitClass = UnitClass
1617
local UnitName = UnitName
1718
local UNKNOWN = UNKNOWN
18-
-- GLOBALS: ElvUF
1919

2020
local tankStatus = {[0] = 3, 2, 1, 0}
2121

ElvUI/Core/init.lua

+5-105
Original file line numberDiff line numberDiff line change
@@ -28,119 +28,22 @@ local SetCVar = C_CVar.SetCVar
2828

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

31-
local ProfilerData, ProfilerReset, Profiler = {}
32-
do -- not finished
33-
local rawset = rawset
34-
local unpack = unpack
35-
local getmetatable = getmetatable
36-
local setmetatable = setmetatable
37-
local debugprofilestop = debugprofilestop
38-
39-
local active = false -- active profiler
40-
local function Generate(object, key, func)
41-
-- print('Generate', object, key, func)
42-
43-
return function(...)
44-
local start = debugprofilestop()
45-
local args = { func(...) }
46-
local finish = debugprofilestop() - start
47-
48-
local obj = ProfilerData[object]
49-
if not obj then
50-
obj = { _module = { total = 0, count = 0 } }
51-
52-
ProfilerData[object] = obj
53-
end
54-
55-
local data = obj[key]
56-
if data then
57-
data.count = data.count + 1
58-
59-
if data.finish > data.high then
60-
data.high = data.finish
61-
end
62-
63-
if data.finish < data.low then
64-
data.low = data.finish
65-
end
66-
67-
data.total = data.total + finish
68-
data.average = data.total / data.count
69-
else
70-
data = { high = finish, low = finish, total = 0, count = 1 }
71-
obj[key] = data
72-
end
73-
74-
-- update data
75-
data.start = start
76-
data.finish = finish
77-
78-
local module = obj._module
79-
if module then -- module totals
80-
module.total = module.total + finish
81-
module.count = module.count + 1
82-
module.average = module.total / module.count
83-
end
84-
85-
local all = ProfilerData._all
86-
if all then -- overall totals
87-
all.total = all.total + finish
88-
all.count = all.count + 1
89-
all.average = all.total / all.count
90-
end
91-
92-
return unpack(args)
93-
end
94-
end
95-
96-
local function Generator(object, key, value)
97-
-- print('Generator', key, value)
98-
99-
if type(value) == 'function' then
100-
local func = Generate(object, key, value)
101-
rawset(object, key, func)
102-
else
103-
rawset(object, key, value)
104-
end
105-
end
106-
107-
ProfilerReset = function()
108-
wipe(ProfilerData)
109-
110-
ProfilerData._all = { total = 0, count = 0 }
111-
end
112-
113-
ProfilerReset() -- set up the data
114-
115-
Profiler = function(tbl, ...)
116-
-- print('Profiler', tbl)
117-
118-
if not active then
119-
return tbl, ...
120-
else
121-
local t = getmetatable(tbl)
122-
if t then
123-
t.__newindex = Generator
124-
125-
return tbl, ...
126-
else
127-
return setmetatable(tbl, { __newindex = Generator }), ...
128-
end
129-
end
130-
end
131-
end
31+
local oUF = _G.ElvUF
32+
assert(oUF, 'ElvUI was unable to locate oUF.')
13233

13334
local AceAddon, AceAddonMinor = _G.LibStub('AceAddon-3.0')
13435
local CallbackHandler = _G.LibStub('CallbackHandler-1.0')
13536

13637
local AddOnName, Engine = ...
38+
local Profiler = oUF.Profiler.func -- ElvUI_CPU knock off by Simpy
13739
local E = Profiler(AceAddon:NewAddon(AddOnName, 'AceConsole-3.0', 'AceEvent-3.0', 'AceTimer-3.0', 'AceHook-3.0'))
138-
E.profiler = {func = Profiler, data = ProfilerData, reset = ProfilerReset} -- ElvUI_CPU knock off by Simpy
13940
E.DF = {profile = {}, global = {}}; E.privateVars = {profile = {}} -- Defaults
14041
E.Options = {type = 'group', args = {}, childGroups = 'ElvUI_HiddenTree', get = E.noop, name = ''}
14142
E.callbacks = E.callbacks or CallbackHandler:New(E)
14243
E.wowpatch, E.wowbuild, E.wowdate, E.wowtoc = GetBuildInfo()
14344
E.locale = GetLocale()
45+
E.Profiler = oUF.Profiler
46+
E.oUF = oUF
14447

14548
Engine[1] = E
14649
Engine[2] = {}
@@ -149,9 +52,6 @@ Engine[4] = E.DF.profile
14952
Engine[5] = E.DF.global
15053
_G.ElvUI = Engine
15154

152-
E.oUF = _G.ElvUF
153-
assert(E.oUF, 'ElvUI was unable to locate oUF.')
154-
15555
E.ActionBars = Profiler(E:NewModule('ActionBars','AceHook-3.0','AceEvent-3.0'))
15656
E.AFK = Profiler(E:NewModule('AFK','AceEvent-3.0','AceTimer-3.0'))
15757
E.Auras = Profiler(E:NewModule('Auras','AceHook-3.0','AceEvent-3.0'))

ElvUI_Libraries/Core/oUF/oUF.xml

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<Ui xmlns="http://www.blizzard.com/wow/ui/">
22
<Script file="init.lua"/>
3+
<Script file="simpy/profiler.lua"/>
4+
<Script file="simpy/pooler.lua"/>
5+
<Script file="simpy/auraskip.lua"/>
36
<Script file="private.lua"/>
47
<Script file="ouf.lua"/>
58
<Script file="events.lua"/>

ElvUI_Libraries/Core/oUF/oUF_Classic.xml

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<Ui xmlns="http://www.blizzard.com/wow/ui/">
22
<Script file="init.lua"/>
3+
<Script file="simpy/profiler.lua"/>
4+
<Script file="simpy/pooler.lua"/>
5+
<Script file="simpy/auraskip.lua"/>
36
<Script file="private.lua"/>
47
<Script file="ouf.lua"/>
58
<Script file="events.lua"/>

ElvUI_Libraries/Core/oUF/oUF_TBC.xml

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<Ui xmlns="http://www.blizzard.com/wow/ui/">
22
<Script file="init.lua"/>
3+
<Script file="simpy/profiler.lua"/>
4+
<Script file="simpy/pooler.lua"/>
5+
<Script file="simpy/auraskip.lua"/>
36
<Script file="private.lua"/>
47
<Script file="ouf.lua"/>
58
<Script file="events.lua"/>

ElvUI_Libraries/Core/oUF/oUF_Wrath.xml

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<Ui xmlns="http://www.blizzard.com/wow/ui/">
22
<Script file="init.lua"/>
3+
<Script file="simpy/profiler.lua"/>
4+
<Script file="simpy/pooler.lua"/>
5+
<Script file="simpy/auraskip.lua"/>
36
<Script file="private.lua"/>
47
<Script file="ouf.lua"/>
58
<Script file="events.lua"/>

0 commit comments

Comments
 (0)