Skip to content

Commit

Permalink
Merge branch 'main' into ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
kodewdle committed Nov 21, 2024
2 parents 175c48f + 586fa2b commit e978983
Show file tree
Hide file tree
Showing 21 changed files with 551 additions and 741 deletions.
3 changes: 2 additions & 1 deletion ElvUI/Core/General/API.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
local E, L, V, P, G = unpack(ElvUI)
local TT = E:GetModule('Tooltip')
local LCS = E.Libs.LCS
local ElvUF = E.oUF

local _G = _G
local type, ipairs, pairs, unpack = type, ipairs, pairs, unpack
Expand Down Expand Up @@ -70,7 +71,7 @@ local GameMenuButtonAddons = GameMenuButtonAddons
local GameMenuButtonLogout = GameMenuButtonLogout
local GameMenuFrame = GameMenuFrame
local UIErrorsFrame = UIErrorsFrame
-- GLOBALS: ElvDB, ElvUF
-- GLOBALS: ElvDB

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

Expand Down
121 changes: 96 additions & 25 deletions ElvUI/Core/General/Commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ local AB = E:GetModule('ActionBars')
local type, pairs, sort, tonumber = type, pairs, sort, tonumber
local lower, wipe, next, print = strlower, wipe, next, print
local ipairs, format, tinsert = ipairs, format, tinsert
local strmatch, gsub = strmatch, gsub

local CopyTable = CopyTable
local ReloadUI = ReloadUI
Expand Down Expand Up @@ -79,19 +80,20 @@ do
local text = ''

function E:BuildProfilerText(tbl, data, overall)
local full = not overall or overall == 2
for _, info in ipairs(tbl) do
if info.key == '_module' then
local all = E.profiler.data._all
local all = E.Profiler.data._all
if all then
local total = info.total or 0
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
elseif not overall then
elseif full then
local total = info.total or 0
local modulePercent = (total / data._module.total) * 100

local all, allPercent = E.profiler.data._all
local all, allPercent = E.Profiler.data._all
if all then
allPercent = (total / all.total) * 100
end
Expand All @@ -100,7 +102,7 @@ do
end
end

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

Expand Down Expand Up @@ -145,33 +147,78 @@ do

function E:GetProfilerData(msg)
local switch = lower(msg)
if switch ~= '' then
if switch == 'e' then
local data = E.profiler.data[E]
if switch == '' then return end

local ouf = switch == 'ouf'
if ouf or switch == 'e' then
local data = E.Profiler.data[ouf and E.oUF or E]
if data then
E:Dump(data, true)
end
elseif switch == 'pooler' then
local data = E.Profiler.data[E.oUF.Pooler]
if data then
E:Dump(data, true)
end
elseif strmatch(switch, '^ouf%s+') then
local element = gsub(switch, '^ouf%s+', '')
if element == '' then return end

for key, module in next, E.oUF.elements do
local data = element == lower(key) and E.Profiler.data[module]
if data then
E:Dump(data, true)
end
else
for key, module in next, E.modules do
local data = switch == lower(key) and E.profiler.data[module]
if data then
E:Dump(data, true)
end
end
else
for key, module in next, E.modules do
local data = switch == lower(key) and E.Profiler.data[module]
if data then
E:Dump(data, true)
end
end
end
end

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

local private = E.Profiler.oUF_Private -- this is special
if private then
E:SortProfilerData('oUF.Private', private, overall)
end

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

for key, module in next, E.oUF.elements do
local info = E.Profiler.data[module]
if info then
E:SortProfilerData(key, info, overall)
end
end
else
local data = E.Profiler.data[E]
if data then
E:SortProfilerData('E', data, overall)
end

local ouf = overall and E.Profiler.data[E.oUF]
if ouf then
E:SortProfilerData('oUF', ouf, 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
end
Expand All @@ -180,19 +227,43 @@ do
local switch = lower(msg)
if switch ~= '' then
if switch == 'reset' then
E.profiler.reset()
E.Profiler.reset()

return E:Print('Reset profiler.')
elseif switch == 'all' then
FetchAll(true)
FetchAll(1)
elseif switch == 'ouf' then
FetchAll(2)
elseif switch == 'e' then
local data = E.profiler.data[E]
local data = E.Profiler.data[E]
if data then
E:SortProfilerData('E', data)
end
elseif switch == 'ouf' then
local data = E.Profiler.data[E.oUF]
if data then
E:SortProfilerData('oUF', data)
end
elseif switch == 'pooler' then
local data = E.Profiler.data[E.oUF.Pooler]
if data then
E:SortProfilerData('oUF.Pooler', data)
end
elseif strmatch(switch, '^ouf%s+') then
local element = gsub(switch, '^ouf%s+', '')
if element ~= '' then
for key, module in next, E.oUF.elements do
local data = element == lower(key) and E.Profiler.data[module]
if data then
E:SortProfilerData(key, data)

break
end
end
end
else
for key, module in next, E.modules do
local data = switch == lower(key) and E.profiler.data[module]
local data = switch == lower(key) and E.Profiler.data[module]
if data then
E:SortProfilerData(key, data)

Expand Down
2 changes: 1 addition & 1 deletion ElvUI/Core/Modules/DataBars/Threat.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local E, L, V, P, G = unpack(ElvUI)
local DB = E:GetModule('DataBars')
local ElvUF = E.oUF

local next = next
local wipe = wipe
Expand All @@ -15,7 +16,6 @@ local UnitIsUnit = UnitIsUnit
local UnitClass = UnitClass
local UnitName = UnitName
local UNKNOWN = UNKNOWN
-- GLOBALS: ElvUF

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

Expand Down
2 changes: 2 additions & 0 deletions ElvUI/Core/Modules/Nameplates/Nameplates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ function NP:NamePlateCallBack(nameplate, event, unit)
nameplate.widgetContainer = nameplate.blizzPlate and nameplate.blizzPlate.WidgetContainer
if nameplate.widgetContainer then
nameplate.widgetContainer:SetParent(nameplate)
nameplate.widgetContainer:SetIgnoreParentAlpha(true)
nameplate.widgetContainer:ClearAllPoints()

local db = NP.db.widgets
Expand Down Expand Up @@ -887,6 +888,7 @@ function NP:NamePlateCallBack(nameplate, event, unit)

if nameplate.widgetContainer then -- Place Widget Back on Blizzard Plate
nameplate.widgetContainer:SetParent(nameplate.blizzPlate)
nameplate.widgetContainer:SetIgnoreParentAlpha(false)
nameplate.widgetContainer:ClearAllPoints()
nameplate.widgetContainer:SetPoint('TOP', nameplate.blizzPlate.castBar, 'BOTTOM')
end
Expand Down
110 changes: 5 additions & 105 deletions ElvUI/Core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,119 +28,22 @@ local SetCVar = C_CVar.SetCVar

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

local ProfilerData, ProfilerReset, Profiler = {}
do -- not finished
local rawset = rawset
local unpack = unpack
local getmetatable = getmetatable
local setmetatable = setmetatable
local debugprofilestop = debugprofilestop

local active = false -- active profiler
local function Generate(object, key, func)
-- print('Generate', object, key, func)

return function(...)
local start = debugprofilestop()
local args = { func(...) }
local finish = debugprofilestop() - start

local obj = ProfilerData[object]
if not obj then
obj = { _module = { total = 0, count = 0 } }

ProfilerData[object] = obj
end

local data = obj[key]
if data then
data.count = data.count + 1

if data.finish > data.high then
data.high = data.finish
end

if data.finish < data.low then
data.low = data.finish
end

data.total = data.total + finish
data.average = data.total / data.count
else
data = { high = finish, low = finish, total = 0, count = 1 }
obj[key] = data
end

-- update data
data.start = start
data.finish = finish

local module = obj._module
if module then -- module totals
module.total = module.total + finish
module.count = module.count + 1
module.average = module.total / module.count
end

local all = ProfilerData._all
if all then -- overall totals
all.total = all.total + finish
all.count = all.count + 1
all.average = all.total / all.count
end

return unpack(args)
end
end

local function Generator(object, key, value)
-- print('Generator', key, value)

if type(value) == 'function' then
local func = Generate(object, key, value)
rawset(object, key, func)
else
rawset(object, key, value)
end
end

ProfilerReset = function()
wipe(ProfilerData)

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

ProfilerReset() -- set up the data

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

if not active then
return tbl, ...
else
local t = getmetatable(tbl)
if t then
t.__newindex = Generator

return tbl, ...
else
return setmetatable(tbl, { __newindex = Generator }), ...
end
end
end
end
local oUF = _G.ElvUF
assert(oUF, 'ElvUI was unable to locate oUF.')

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

local AddOnName, Engine = ...
local Profiler = oUF.Profiler.func -- ElvUI_CPU knock off by Simpy
local E = Profiler(AceAddon:NewAddon(AddOnName, 'AceConsole-3.0', 'AceEvent-3.0', 'AceTimer-3.0', 'AceHook-3.0'))
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)
E.wowpatch, E.wowbuild, E.wowdate, E.wowtoc = GetBuildInfo()
E.locale = GetLocale()
E.Profiler = oUF.Profiler
E.oUF = oUF

Engine[1] = E
Engine[2] = {}
Expand All @@ -149,9 +52,6 @@ Engine[4] = E.DF.profile
Engine[5] = E.DF.global
_G.ElvUI = Engine

E.oUF = _G.ElvUF
assert(E.oUF, 'ElvUI was unable to locate oUF.')

E.ActionBars = Profiler(E:NewModule('ActionBars','AceHook-3.0','AceEvent-3.0'))
E.AFK = Profiler(E:NewModule('AFK','AceEvent-3.0','AceTimer-3.0'))
E.Auras = Profiler(E:NewModule('Auras','AceHook-3.0','AceEvent-3.0'))
Expand Down
2 changes: 1 addition & 1 deletion ElvUI_Libraries/Core/oUF/blizzard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local _, ns = ...
local oUF = ns.oUF

-- sourced from Blizzard_UnitFrame/TargetFrame.lua
local MAX_BOSS_FRAMES = 8
local MAX_BOSS_FRAMES = 8 -- blizzard can spawn more than the default 5 apparently

-- sourced from Blizzard_FrameXMLBase/Shared/Constants.lua
local MEMBERS_PER_RAID_GROUP = _G.MEMBERS_PER_RAID_GROUP or 5
Expand Down
Loading

0 comments on commit e978983

Please sign in to comment.