dpslog: single CombatLogGetCurrentEventInfo call per event

Both DPSMate and WSBT adapters now call CombatLogGetCurrentEventInfo()
exactly once per event, unpacking all args into p1..p12 locals.
Remove redundant relevance check in WSBT profiling wrapper.
This commit is contained in:
MarcelineVQ
2026-03-18 17:47:53 -07:00
parent d84f723539
commit 34bb70dc8b
2 changed files with 56 additions and 104 deletions
+30 -60
View File
@@ -206,7 +206,9 @@ local cleuHandler
cleuHandler = function() cleuHandler = function()
if not CombatLogGetCurrentEventInfo then return end if not CombatLogGetCurrentEventInfo then return end
local sub, srcGUID, srcName, srcFlags, srcRaidFlags, local sub, srcGUID, srcName, srcFlags, srcRaidFlags,
dstGUID, dstName, dstFlags, dstRaidFlags = CombatLogGetCurrentEventInfo() dstGUID, dstName, dstFlags, dstRaidFlags,
p1, p2, p3, p4, p5, p6, p7, p8, p9,
p10, p11, p12 = CombatLogGetCurrentEventInfo()
if not sub then return end if not sub then return end
if not srcName or srcName == "" then srcName = "Unknown" end if not srcName or srcName == "" then srcName = "Unknown" end
@@ -221,12 +223,10 @@ cleuHandler = function()
if sub == "SWING_DAMAGE" then if sub == "SWING_DAMAGE" then
local dir, name = getDirection(srcName, dstName) local dir, name = getDirection(srcName, dstName)
if not dir then return end if not dir then return end
local _, _, _, _, _, _, _, _, _, local amount, resisted, blocked, absorbed = p1, p4, p5, p6
amount, overkill, school, resisted, blocked, absorbed, local glancing = p8 and 1 or 0
critical, glancing, crushing = CombatLogGetCurrentEventInfo() local crushing = p9 and 1 or 0
glancing = glancing and 1 or 0 local hitType = p7 and HIT_CRIT or HIT_NORMAL
crushing = crushing and 1 or 0
local hitType = critical and HIT_CRIT or HIT_NORMAL
local data = GetDamageData(dir, HIT, hitType, DMG_PHYSICAL, amount, nil, name) local data = GetDamageData(dir, HIT, hitType, DMG_PHYSICAL, amount, nil, name)
applyPartials(data, resisted, blocked, absorbed, glancing, crushing) applyPartials(data, resisted, blocked, absorbed, glancing, crushing)
@@ -240,8 +240,7 @@ cleuHandler = function()
elseif sub == "SWING_MISSED" then elseif sub == "SWING_MISSED" then
local dir, name = getDirection(srcName, dstName) local dir, name = getDirection(srcName, dstName)
if not dir then return end if not dir then return end
local _, _, _, _, _, _, _, _, _, missType = CombatLogGetCurrentEventInfo() local action = missActionMap[p1] or MISS
local action = missActionMap[missType] or MISS
local data = GetDamageData(dir, action, nil, nil, nil, nil, name) local data = GetDamageData(dir, action, nil, nil, nil, nil, name)
SendEvent(data) SendEvent(data)
@@ -256,13 +255,11 @@ cleuHandler = function()
or sub == "DAMAGE_SPLIT" then or sub == "DAMAGE_SPLIT" then
local dir, name = getDirection(srcName, dstName) local dir, name = getDirection(srcName, dstName)
if not dir then return end if not dir then return end
local _, _, _, _, _, _, _, _, _, local spellName = p2
spellId, spellName, spellSchool, local amount, school, resisted, blocked, absorbed = p4, p6, p7, p8, p9
amount, overkill, school, resisted, blocked, absorbed, local crushing = p12 and 1 or 0
critical, glancing, crushing = CombatLogGetCurrentEventInfo() local hitType = p10 and HIT_CRIT or HIT_NORMAL
crushing = crushing and 1 or 0 local dmgType = schoolToDamageType(school)
local hitType = critical and HIT_CRIT or HIT_NORMAL
local dmgType = schoolToDamageType(school)
local data = GetDamageData(dir, HIT, hitType, dmgType, amount, spellName, name) local data = GetDamageData(dir, HIT, hitType, dmgType, amount, spellName, name)
applyPartials(data, resisted, blocked, absorbed, 0, crushing) applyPartials(data, resisted, blocked, absorbed, 0, crushing)
@@ -271,11 +268,9 @@ cleuHandler = function()
elseif sub == "SPELL_PERIODIC_DAMAGE" then elseif sub == "SPELL_PERIODIC_DAMAGE" then
local dir, name = getDirection(srcName, dstName) local dir, name = getDirection(srcName, dstName)
if not dir then return end if not dir then return end
local _, _, _, _, _, _, _, _, _, local spellName = p2
spellId, spellName, spellSchool, local amount, school, resisted, absorbed = p4, p6, p7, p9
amount, overkill, school, resisted, blocked, absorbed = CombatLogGetCurrentEventInfo() local dmgType = schoolToDamageType(school)
-- numbers always non-nil from CombatLogGetCurrentEventInfo
local dmgType = schoolToDamageType(school)
local data = GetDamageData(dir, HIT, HIT_DOT, dmgType, amount, spellName, name) local data = GetDamageData(dir, HIT, HIT_DOT, dmgType, amount, spellName, name)
applyPartials(data, resisted, 0, absorbed, 0, 0) applyPartials(data, resisted, 0, absorbed, 0, 0)
@@ -291,8 +286,7 @@ cleuHandler = function()
or sub == "SPELL_PERIODIC_MISSED" or sub == "DAMAGE_SHIELD_MISSED" then or sub == "SPELL_PERIODIC_MISSED" or sub == "DAMAGE_SHIELD_MISSED" then
local dir, name = getDirection(srcName, dstName) local dir, name = getDirection(srcName, dstName)
if not dir then return end if not dir then return end
local _, _, _, _, _, _, _, _, _, local spellName, missType = p2, p4
spellId, spellName, spellSchool, missType = CombatLogGetCurrentEventInfo()
local action = missActionMap[missType] or MISS local action = missActionMap[missType] or MISS
local data = GetDamageData(dir, action, nil, nil, nil, spellName, name) local data = GetDamageData(dir, action, nil, nil, nil, spellName, name)
SendEvent(data) SendEvent(data)
@@ -305,7 +299,7 @@ cleuHandler = function()
elseif sub == "ENVIRONMENTAL_DAMAGE" then elseif sub == "ENVIRONMENTAL_DAMAGE" then
if dstName ~= playerName then return end if dstName ~= playerName then return end
local _, _, _, _, _, _, _, _, _, envType, amount = CombatLogGetCurrentEventInfo() local envType, amount = p1, p2
local action = envActionMap[envType] or HIT local action = envActionMap[envType] or HIT
local data = GetDamageData(INCOMING, action, HIT_NORMAL, DMG_PHYSICAL, amount, nil, envType or "Environment") local data = GetDamageData(INCOMING, action, HIT_NORMAL, DMG_PHYSICAL, amount, nil, envType or "Environment")
SendEvent(data) SendEvent(data)
@@ -319,9 +313,8 @@ cleuHandler = function()
elseif sub == "SPELL_HEAL" or sub == "SPELL_PERIODIC_HEAL" then elseif sub == "SPELL_HEAL" or sub == "SPELL_PERIODIC_HEAL" then
local dir, name = getDirection(srcName, dstName) local dir, name = getDirection(srcName, dstName)
if not dir then return end if not dir then return end
local _, _, _, _, _, _, _, _, _, local spellName = p2
spellId, spellName, spellSchool, local amount, overheal, critical = p4, p5, p7
amount, overheal, absorbed, critical = CombatLogGetCurrentEventInfo()
local isPeriodic = (sub == "SPELL_PERIODIC_HEAL") local isPeriodic = (sub == "SPELL_PERIODIC_HEAL")
local healType local healType
@@ -352,9 +345,8 @@ cleuHandler = function()
elseif sub == "SPELL_ENERGIZE" or sub == "SPELL_PERIODIC_ENERGIZE" then elseif sub == "SPELL_ENERGIZE" or sub == "SPELL_PERIODIC_ENERGIZE" then
if dstName ~= playerName then return end if dstName ~= playerName then return end
local _, _, _, _, _, _, _, _, _, local spellName, amount, powerType = p2, p4, p5
spellId, spellName, spellSchool, amount, powerType = CombatLogGetCurrentEventInfo() local powerName = powerTypeNames[powerType] or "Mana"
local powerName = powerTypeNames[powerType] or "Mana"
local data = GetNotifData(NOTIF_POWER_GAIN, amount .. " " .. powerName, spellName) local data = GetNotifData(NOTIF_POWER_GAIN, amount .. " " .. powerName, spellName)
SendEvent(data) SendEvent(data)
@@ -366,8 +358,7 @@ cleuHandler = function()
elseif sub == "SPELL_PERIODIC_DRAIN" then elseif sub == "SPELL_PERIODIC_DRAIN" then
if dstName ~= playerName then return end if dstName ~= playerName then return end
local _, _, _, _, _, _, _, _, _, local spellName, amount, powerType = p2, p4, p5
spellId, spellName, spellSchool, amount, powerType = CombatLogGetCurrentEventInfo()
local powerName = powerTypeNames[powerType] or "Mana" local powerName = powerTypeNames[powerType] or "Mana"
local data = GetNotifData(NOTIF_POWER_LOSS, amount .. " " .. powerName, spellName) local data = GetNotifData(NOTIF_POWER_LOSS, amount .. " " .. powerName, spellName)
SendEvent(data) SendEvent(data)
@@ -375,8 +366,7 @@ cleuHandler = function()
elseif sub == "SPELL_PERIODIC_LEECH" then elseif sub == "SPELL_PERIODIC_LEECH" then
local dir, name = getDirection(srcName, dstName) local dir, name = getDirection(srcName, dstName)
if not dir then return end if not dir then return end
local _, _, _, _, _, _, _, _, _, local spellName, spellSchool, amount = p2, p3, p4
spellId, spellName, spellSchool, amount = CombatLogGetCurrentEventInfo()
local dmgType = schoolToDamageType(spellSchool) local dmgType = schoolToDamageType(spellSchool)
local data = GetDamageData(dir, HIT, HIT_DOT, dmgType, amount, spellName, name) local data = GetDamageData(dir, HIT, HIT_DOT, dmgType, amount, spellName, name)
SendEvent(data) SendEvent(data)
@@ -389,8 +379,7 @@ cleuHandler = function()
elseif sub == "SPELL_AURA_APPLIED" then elseif sub == "SPELL_AURA_APPLIED" then
if dstName ~= playerName then return end if dstName ~= playerName then return end
local _, _, _, _, _, _, _, _, _, local spellName, auraType = p2, p4
spellId, spellName, spellSchool, auraType = CombatLogGetCurrentEventInfo()
if auraType == "DEBUFF" then if auraType == "DEBUFF" then
local data = GetNotifData(NOTIF_DEBUFF, nil, spellName) local data = GetNotifData(NOTIF_DEBUFF, nil, spellName)
SendEvent(data) SendEvent(data)
@@ -401,7 +390,7 @@ cleuHandler = function()
elseif sub == "SPELL_AURA_REMOVED" then elseif sub == "SPELL_AURA_REMOVED" then
if dstName ~= playerName then return end if dstName ~= playerName then return end
local _, _, _, _, _, _, _, _, _, spellId, spellName = CombatLogGetCurrentEventInfo() local spellName = p2
local data = GetNotifData(NOTIF_BUFF_FADE, nil, spellName) local data = GetNotifData(NOTIF_BUFF_FADE, nil, spellName)
SendEvent(data) SendEvent(data)
@@ -447,27 +436,13 @@ end
-- Patch MikCEH.OnEvent so the XML OnEvent handler calls the measured version -- Patch MikCEH.OnEvent so the XML OnEvent handler calls the measured version
MikCEH.OnEvent = measuredOrigOnEvent MikCEH.OnEvent = measuredOrigOnEvent
local cleuEventsSkipped = 0
local function measuredCLEUHandler() local function measuredCLEUHandler()
if profiling and profCurrent == profCLEU then if profiling and profCurrent == profCLEU then
-- Quick relevance check: is player or pet involved?
local _, _, srcName, _, _, _, dstName = CombatLogGetCurrentEventInfo()
srcName = srcName or ""
dstName = dstName or ""
local relevant = (srcName == playerName or dstName == playerName
or (petName and (srcName == petName or dstName == petName)))
local before = debugprofilestop() local before = debugprofilestop()
cleuHandler() cleuHandler()
local after = debugprofilestop() local after = debugprofilestop()
profCLEU.totalMs = profCLEU.totalMs + (after - before)
if relevant then profCLEU.events = profCLEU.events + 1
profCLEU.totalMs = profCLEU.totalMs + (after - before)
profCLEU.events = profCLEU.events + 1
else
cleuEventsSkipped = cleuEventsSkipped + 1
end
else else
cleuHandler() cleuHandler()
end end
@@ -496,14 +471,9 @@ local function profReport(label, tbl)
lastOrigAvg = avgUs lastOrigAvg = avgUs
end end
local skipMsg = ""
if label == "CLEU" then
skipMsg = string.format(" (%d skipped)", cleuEventsSkipped)
cleuEventsSkipped = 0
end
DEFAULT_CHAT_FRAME:AddMessage(string.format( DEFAULT_CHAT_FRAME:AddMessage(string.format(
"|cff00ff00[WSBT %s]|r %d events%s, %.1fms total, %.1f us/event, %+.1f KB gc", "|cff00ff00[WSBT %s]|r %d events, %.1fms total, %.1f us/event, %+.1f KB gc",
label, tbl.events, skipMsg, totalMs, avgUs, gcDelta)) label, tbl.events, totalMs, avgUs, gcDelta))
if lastCLEUAvg and lastOrigAvg and lastOrigAvg > 0 then if lastCLEUAvg and lastOrigAvg and lastOrigAvg > 0 then
local pct = ((lastCLEUAvg - lastOrigAvg) / lastOrigAvg) * 100 local pct = ((lastCLEUAvg - lastOrigAvg) / lastOrigAvg) * 100
+26 -44
View File
@@ -280,8 +280,14 @@ local FailDB = DPSMate.Parser.FailDB
cleuHandler = function() cleuHandler = function()
if not CombatLogGetCurrentEventInfo then return end if not CombatLogGetCurrentEventInfo then return end
-- Single call — positions differ by prefix type:
-- Swing: p1=amount, p2=overkill, p3=school, ...
-- Spell: p1=spellId, p2=spellName, p3=spellSchool, p4=amount, ...
-- Env: p1=envType, p2=amount, ...
local sub, srcGUID, srcName, srcFlags, srcRaidFlags, local sub, srcGUID, srcName, srcFlags, srcRaidFlags,
dstGUID, dstName, dstFlags, dstRaidFlags = CombatLogGetCurrentEventInfo() dstGUID, dstName, dstFlags, dstRaidFlags,
p1, p2, p3, p4, p5, p6, p7, p8, p9,
p10, p11, p12 = CombatLogGetCurrentEventInfo()
if not sub then return end if not sub then return end
if not srcName or srcName == "" then srcName = "Unknown" end if not srcName or srcName == "" then srcName = "Unknown" end
@@ -290,13 +296,10 @@ cleuHandler = function()
-- ======================================================================== -- ========================================================================
-- DAMAGE events -- DAMAGE events
-- ======================================================================== -- ========================================================================
-- SWING_DAMAGE: (base 9), amount, overkill, school, resisted,
-- blocked, absorbed, critical, glancing, crushing
if sub == "SWING_DAMAGE" then if sub == "SWING_DAMAGE" then
local _, _, _, _, _, _, _, _, _, local amount, absorbed = p1, p6
amount, overkill, school, resisted, blocked, absorbed, local critical, glancing, crushing = p7, p8, p9
critical, glancing, crushing = CombatLogGetCurrentEventInfo()
-- numbers always non-nil from CombatLogGetCurrentEventInfo -- numbers always non-nil from CombatLogGetCurrentEventInfo
local crit = critical and 1 or 0 local crit = critical and 1 or 0
local glanc = glancing and 1 or 0 local glanc = glancing and 1 or 0
@@ -314,8 +317,7 @@ cleuHandler = function()
end end
elseif sub == "SWING_MISSED" then elseif sub == "SWING_MISSED" then
local _, _, _, _, _, _, _, _, _, local missType = p1
missType = CombatLogGetCurrentEventInfo()
local miss = (missType == "MISS") and 1 or 0 local miss = (missType == "MISS") and 1 or 0
local parry = (missType == "PARRY") and 1 or 0 local parry = (missType == "PARRY") and 1 or 0
local dodge = (missType == "DODGE") and 1 or 0 local dodge = (missType == "DODGE") and 1 or 0
@@ -334,11 +336,9 @@ cleuHandler = function()
elseif sub == "SPELL_DAMAGE" or sub == "RANGE_DAMAGE" or sub == "SPELL_PERIODIC_DAMAGE" elseif sub == "SPELL_DAMAGE" or sub == "RANGE_DAMAGE" or sub == "SPELL_PERIODIC_DAMAGE"
or sub == "DAMAGE_SHIELD" or sub == "DAMAGE_SPLIT" then or sub == "DAMAGE_SHIELD" or sub == "DAMAGE_SPLIT" then
local _, _, _, _, _, _, _, _, _, local spellName, spellSchool = p2, p3
spellId, spellName, spellSchool, local amount, absorbed = p4, p9
amount, overkill, school, resisted, blocked, absorbed, local critical, glancing, crushing = p10, p11, p12
critical, glancing, crushing = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
-- numbers always non-nil from CombatLogGetCurrentEventInfo -- numbers always non-nil from CombatLogGetCurrentEventInfo
local crit = critical and 1 or 0 local crit = critical and 1 or 0
local glanc = glancing and 1 or 0 local glanc = glancing and 1 or 0
@@ -362,10 +362,8 @@ cleuHandler = function()
elseif sub == "SPELL_MISSED" or sub == "RANGE_MISSED" elseif sub == "SPELL_MISSED" or sub == "RANGE_MISSED"
or sub == "SPELL_PERIODIC_MISSED" or sub == "DAMAGE_SHIELD_MISSED" then or sub == "SPELL_PERIODIC_MISSED" or sub == "DAMAGE_SHIELD_MISSED" then
local _, _, _, _, _, _, _, _, _, local spellName = p2
spellId, spellName, spellSchool, local missType = p4
missType = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
local miss = (missType == "MISS") and 1 or 0 local miss = (missType == "MISS") and 1 or 0
local parry = (missType == "PARRY") and 1 or 0 local parry = (missType == "PARRY") and 1 or 0
local dodge = (missType == "DODGE") and 1 or 0 local dodge = (missType == "DODGE") and 1 or 0
@@ -382,8 +380,7 @@ cleuHandler = function()
end end
elseif sub == "ENVIRONMENTAL_DAMAGE" then elseif sub == "ENVIRONMENTAL_DAMAGE" then
local _, _, _, _, _, _, _, _, _, local envType, amount = p1, p2
envType, amount = CombatLogGetCurrentEventInfo()
DB:DamageTaken(dstName, envType or "Environment", 1, 0, 0, 0, 0, 0, amount, envType or "Environment", 0, 0) DB:DamageTaken(dstName, envType or "Environment", 1, 0, 0, 0, 0, 0, amount, envType or "Environment", 0, 0)
DB:DeathHistory(dstName, envType or "Environment", envType or "Environment", amount, 1, 0, "hit", 0) DB:DeathHistory(dstName, envType or "Environment", envType or "Environment", amount, 1, 0, "hit", 0)
@@ -392,9 +389,8 @@ cleuHandler = function()
-- ======================================================================== -- ========================================================================
elseif sub == "SPELL_HEAL" or sub == "SPELL_PERIODIC_HEAL" then elseif sub == "SPELL_HEAL" or sub == "SPELL_PERIODIC_HEAL" then
local _, _, _, _, _, _, _, _, _, local spellName = p2
spellId, spellName, spellSchool, local amount, overheal, absorbed, critical = p4, p5, p6, p7
amount, overheal, absorbed, critical = CombatLogGetCurrentEventInfo()
local crit = critical and 1 or 0 local crit = critical and 1 or 0
local hit = crit == 0 and 1 or 0 local hit = crit == 0 and 1 or 0
local effective = amount - overheal local effective = amount - overheal
@@ -410,9 +406,7 @@ cleuHandler = function()
-- ======================================================================== -- ========================================================================
elseif sub == "SPELL_AURA_APPLIED" then elseif sub == "SPELL_AURA_APPLIED" then
local _, _, _, _, _, _, _, _, _, local spellName, auraType = p2, p4
spellId, spellName, spellSchool, auraType = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
if auraType == "DEBUFF" then if auraType == "DEBUFF" then
DB:BuildBuffs(srcName, dstName, spellName, false) DB:BuildBuffs(srcName, dstName, spellName, false)
if Parser.CC[spellName] then if Parser.CC[spellName] then
@@ -429,9 +423,7 @@ cleuHandler = function()
end end
elseif sub == "SPELL_AURA_REMOVED" then elseif sub == "SPELL_AURA_REMOVED" then
local _, _, _, _, _, _, _, _, _, local spellName, auraType = p2, p4
spellId, spellName, spellSchool, auraType = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
DB:DestroyBuffs(dstName, spellName) DB:DestroyBuffs(dstName, spellName)
if auraType == "DEBUFF" then if auraType == "DEBUFF" then
DB:RemoveActiveCC(dstName, spellName) DB:RemoveActiveCC(dstName, spellName)
@@ -442,9 +434,7 @@ cleuHandler = function()
end end
elseif sub == "SPELL_AURA_BROKEN_SPELL" or sub == "SPELL_AURA_BROKEN" then elseif sub == "SPELL_AURA_BROKEN_SPELL" or sub == "SPELL_AURA_BROKEN" then
local _, _, _, _, _, _, _, _, _, local spellName = p2
spellId, spellName = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
DB:RemoveActiveCC(dstName, spellName) DB:RemoveActiveCC(dstName, spellName)
if Parser.CC[spellName] then if Parser.CC[spellName] then
DB:CCBreaker(dstName, spellName, srcName) DB:CCBreaker(dstName, spellName, srcName)
@@ -455,9 +445,7 @@ cleuHandler = function()
-- ======================================================================== -- ========================================================================
elseif sub == "SPELL_CAST_SUCCESS" then elseif sub == "SPELL_CAST_SUCCESS" then
local _, _, _, _, _, _, _, _, _, local spellName = p2
spellId, spellName = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
if Parser.Kicks and Parser.Kicks[spellName] then if Parser.Kicks and Parser.Kicks[spellName] then
DB:RegisterPotentialKick(srcName, spellName, GT()) DB:RegisterPotentialKick(srcName, spellName, GT())
end end
@@ -470,19 +458,13 @@ cleuHandler = function()
-- ======================================================================== -- ========================================================================
elseif sub == "SPELL_INTERRUPT" then elseif sub == "SPELL_INTERRUPT" then
local _, _, _, _, _, _, _, _, _, local spellName = p2
spellId, spellName, spellSchool, local extraSpellName = p5
extraSpellId, extraSpellName = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
extraSpellName = extraSpellName or "Unknown"
DB:Kick(srcName, dstName, spellName, extraSpellName) DB:Kick(srcName, dstName, spellName, extraSpellName)
elseif sub == "SPELL_DISPEL" then elseif sub == "SPELL_DISPEL" then
local _, _, _, _, _, _, _, _, _, local spellName = p2
spellId, spellName, spellSchool, local extraSpellName = p5
extraSpellId, extraSpellName = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
extraSpellName = extraSpellName or "Unknown"
if isGroupMember(srcName) then if isGroupMember(srcName) then
DB:Dispels(srcName, spellName, dstName, extraSpellName) DB:Dispels(srcName, spellName, dstName, extraSpellName)
end end