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()
if not CombatLogGetCurrentEventInfo then return end
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 srcName or srcName == "" then srcName = "Unknown" end
@@ -221,12 +223,10 @@ cleuHandler = function()
if sub == "SWING_DAMAGE" then
local dir, name = getDirection(srcName, dstName)
if not dir then return end
local _, _, _, _, _, _, _, _, _,
amount, overkill, school, resisted, blocked, absorbed,
critical, glancing, crushing = CombatLogGetCurrentEventInfo()
glancing = glancing and 1 or 0
crushing = crushing and 1 or 0
local hitType = critical and HIT_CRIT or HIT_NORMAL
local amount, resisted, blocked, absorbed = p1, p4, p5, p6
local glancing = p8 and 1 or 0
local crushing = p9 and 1 or 0
local hitType = p7 and HIT_CRIT or HIT_NORMAL
local data = GetDamageData(dir, HIT, hitType, DMG_PHYSICAL, amount, nil, name)
applyPartials(data, resisted, blocked, absorbed, glancing, crushing)
@@ -240,8 +240,7 @@ cleuHandler = function()
elseif sub == "SWING_MISSED" then
local dir, name = getDirection(srcName, dstName)
if not dir then return end
local _, _, _, _, _, _, _, _, _, missType = CombatLogGetCurrentEventInfo()
local action = missActionMap[missType] or MISS
local action = missActionMap[p1] or MISS
local data = GetDamageData(dir, action, nil, nil, nil, nil, name)
SendEvent(data)
@@ -256,13 +255,11 @@ cleuHandler = function()
or sub == "DAMAGE_SPLIT" then
local dir, name = getDirection(srcName, dstName)
if not dir then return end
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool,
amount, overkill, school, resisted, blocked, absorbed,
critical, glancing, crushing = CombatLogGetCurrentEventInfo()
crushing = crushing and 1 or 0
local hitType = critical and HIT_CRIT or HIT_NORMAL
local dmgType = schoolToDamageType(school)
local spellName = p2
local amount, school, resisted, blocked, absorbed = p4, p6, p7, p8, p9
local crushing = p12 and 1 or 0
local hitType = p10 and HIT_CRIT or HIT_NORMAL
local dmgType = schoolToDamageType(school)
local data = GetDamageData(dir, HIT, hitType, dmgType, amount, spellName, name)
applyPartials(data, resisted, blocked, absorbed, 0, crushing)
@@ -271,11 +268,9 @@ cleuHandler = function()
elseif sub == "SPELL_PERIODIC_DAMAGE" then
local dir, name = getDirection(srcName, dstName)
if not dir then return end
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool,
amount, overkill, school, resisted, blocked, absorbed = CombatLogGetCurrentEventInfo()
-- numbers always non-nil from CombatLogGetCurrentEventInfo
local dmgType = schoolToDamageType(school)
local spellName = p2
local amount, school, resisted, absorbed = p4, p6, p7, p9
local dmgType = schoolToDamageType(school)
local data = GetDamageData(dir, HIT, HIT_DOT, dmgType, amount, spellName, name)
applyPartials(data, resisted, 0, absorbed, 0, 0)
@@ -291,8 +286,7 @@ cleuHandler = function()
or sub == "SPELL_PERIODIC_MISSED" or sub == "DAMAGE_SHIELD_MISSED" then
local dir, name = getDirection(srcName, dstName)
if not dir then return end
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool, missType = CombatLogGetCurrentEventInfo()
local spellName, missType = p2, p4
local action = missActionMap[missType] or MISS
local data = GetDamageData(dir, action, nil, nil, nil, spellName, name)
SendEvent(data)
@@ -305,7 +299,7 @@ cleuHandler = function()
elseif sub == "ENVIRONMENTAL_DAMAGE" then
if dstName ~= playerName then return end
local _, _, _, _, _, _, _, _, _, envType, amount = CombatLogGetCurrentEventInfo()
local envType, amount = p1, p2
local action = envActionMap[envType] or HIT
local data = GetDamageData(INCOMING, action, HIT_NORMAL, DMG_PHYSICAL, amount, nil, envType or "Environment")
SendEvent(data)
@@ -319,9 +313,8 @@ cleuHandler = function()
elseif sub == "SPELL_HEAL" or sub == "SPELL_PERIODIC_HEAL" then
local dir, name = getDirection(srcName, dstName)
if not dir then return end
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool,
amount, overheal, absorbed, critical = CombatLogGetCurrentEventInfo()
local spellName = p2
local amount, overheal, critical = p4, p5, p7
local isPeriodic = (sub == "SPELL_PERIODIC_HEAL")
local healType
@@ -352,9 +345,8 @@ cleuHandler = function()
elseif sub == "SPELL_ENERGIZE" or sub == "SPELL_PERIODIC_ENERGIZE" then
if dstName ~= playerName then return end
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool, amount, powerType = CombatLogGetCurrentEventInfo()
local powerName = powerTypeNames[powerType] or "Mana"
local spellName, amount, powerType = p2, p4, p5
local powerName = powerTypeNames[powerType] or "Mana"
local data = GetNotifData(NOTIF_POWER_GAIN, amount .. " " .. powerName, spellName)
SendEvent(data)
@@ -366,8 +358,7 @@ cleuHandler = function()
elseif sub == "SPELL_PERIODIC_DRAIN" then
if dstName ~= playerName then return end
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool, amount, powerType = CombatLogGetCurrentEventInfo()
local spellName, amount, powerType = p2, p4, p5
local powerName = powerTypeNames[powerType] or "Mana"
local data = GetNotifData(NOTIF_POWER_LOSS, amount .. " " .. powerName, spellName)
SendEvent(data)
@@ -375,8 +366,7 @@ cleuHandler = function()
elseif sub == "SPELL_PERIODIC_LEECH" then
local dir, name = getDirection(srcName, dstName)
if not dir then return end
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool, amount = CombatLogGetCurrentEventInfo()
local spellName, spellSchool, amount = p2, p3, p4
local dmgType = schoolToDamageType(spellSchool)
local data = GetDamageData(dir, HIT, HIT_DOT, dmgType, amount, spellName, name)
SendEvent(data)
@@ -389,8 +379,7 @@ cleuHandler = function()
elseif sub == "SPELL_AURA_APPLIED" then
if dstName ~= playerName then return end
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool, auraType = CombatLogGetCurrentEventInfo()
local spellName, auraType = p2, p4
if auraType == "DEBUFF" then
local data = GetNotifData(NOTIF_DEBUFF, nil, spellName)
SendEvent(data)
@@ -401,7 +390,7 @@ cleuHandler = function()
elseif sub == "SPELL_AURA_REMOVED" then
if dstName ~= playerName then return end
local _, _, _, _, _, _, _, _, _, spellId, spellName = CombatLogGetCurrentEventInfo()
local spellName = p2
local data = GetNotifData(NOTIF_BUFF_FADE, nil, spellName)
SendEvent(data)
@@ -447,27 +436,13 @@ end
-- Patch MikCEH.OnEvent so the XML OnEvent handler calls the measured version
MikCEH.OnEvent = measuredOrigOnEvent
local cleuEventsSkipped = 0
local function measuredCLEUHandler()
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()
cleuHandler()
local after = debugprofilestop()
if relevant then
profCLEU.totalMs = profCLEU.totalMs + (after - before)
profCLEU.events = profCLEU.events + 1
else
cleuEventsSkipped = cleuEventsSkipped + 1
end
profCLEU.totalMs = profCLEU.totalMs + (after - before)
profCLEU.events = profCLEU.events + 1
else
cleuHandler()
end
@@ -496,14 +471,9 @@ local function profReport(label, tbl)
lastOrigAvg = avgUs
end
local skipMsg = ""
if label == "CLEU" then
skipMsg = string.format(" (%d skipped)", cleuEventsSkipped)
cleuEventsSkipped = 0
end
DEFAULT_CHAT_FRAME:AddMessage(string.format(
"|cff00ff00[WSBT %s]|r %d events%s, %.1fms total, %.1f us/event, %+.1f KB gc",
label, tbl.events, skipMsg, totalMs, avgUs, gcDelta))
"|cff00ff00[WSBT %s]|r %d events, %.1fms total, %.1f us/event, %+.1f KB gc",
label, tbl.events, totalMs, avgUs, gcDelta))
if lastCLEUAvg and lastOrigAvg and lastOrigAvg > 0 then
local pct = ((lastCLEUAvg - lastOrigAvg) / lastOrigAvg) * 100
+26 -44
View File
@@ -280,8 +280,14 @@ local FailDB = DPSMate.Parser.FailDB
cleuHandler = function()
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,
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 srcName or srcName == "" then srcName = "Unknown" end
@@ -290,13 +296,10 @@ cleuHandler = function()
-- ========================================================================
-- DAMAGE events
-- ========================================================================
-- SWING_DAMAGE: (base 9), amount, overkill, school, resisted,
-- blocked, absorbed, critical, glancing, crushing
if sub == "SWING_DAMAGE" then
local _, _, _, _, _, _, _, _, _,
amount, overkill, school, resisted, blocked, absorbed,
critical, glancing, crushing = CombatLogGetCurrentEventInfo()
local amount, absorbed = p1, p6
local critical, glancing, crushing = p7, p8, p9
-- numbers always non-nil from CombatLogGetCurrentEventInfo
local crit = critical and 1 or 0
local glanc = glancing and 1 or 0
@@ -314,8 +317,7 @@ cleuHandler = function()
end
elseif sub == "SWING_MISSED" then
local _, _, _, _, _, _, _, _, _,
missType = CombatLogGetCurrentEventInfo()
local missType = p1
local miss = (missType == "MISS") and 1 or 0
local parry = (missType == "PARRY") 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"
or sub == "DAMAGE_SHIELD" or sub == "DAMAGE_SPLIT" then
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool,
amount, overkill, school, resisted, blocked, absorbed,
critical, glancing, crushing = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
local spellName, spellSchool = p2, p3
local amount, absorbed = p4, p9
local critical, glancing, crushing = p10, p11, p12
-- numbers always non-nil from CombatLogGetCurrentEventInfo
local crit = critical 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"
or sub == "SPELL_PERIODIC_MISSED" or sub == "DAMAGE_SHIELD_MISSED" then
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool,
missType = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
local spellName = p2
local missType = p4
local miss = (missType == "MISS") and 1 or 0
local parry = (missType == "PARRY") and 1 or 0
local dodge = (missType == "DODGE") and 1 or 0
@@ -382,8 +380,7 @@ cleuHandler = function()
end
elseif sub == "ENVIRONMENTAL_DAMAGE" then
local _, _, _, _, _, _, _, _, _,
envType, amount = CombatLogGetCurrentEventInfo()
local envType, amount = p1, p2
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)
@@ -392,9 +389,8 @@ cleuHandler = function()
-- ========================================================================
elseif sub == "SPELL_HEAL" or sub == "SPELL_PERIODIC_HEAL" then
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool,
amount, overheal, absorbed, critical = CombatLogGetCurrentEventInfo()
local spellName = p2
local amount, overheal, absorbed, critical = p4, p5, p6, p7
local crit = critical and 1 or 0
local hit = crit == 0 and 1 or 0
local effective = amount - overheal
@@ -410,9 +406,7 @@ cleuHandler = function()
-- ========================================================================
elseif sub == "SPELL_AURA_APPLIED" then
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool, auraType = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
local spellName, auraType = p2, p4
if auraType == "DEBUFF" then
DB:BuildBuffs(srcName, dstName, spellName, false)
if Parser.CC[spellName] then
@@ -429,9 +423,7 @@ cleuHandler = function()
end
elseif sub == "SPELL_AURA_REMOVED" then
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool, auraType = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
local spellName, auraType = p2, p4
DB:DestroyBuffs(dstName, spellName)
if auraType == "DEBUFF" then
DB:RemoveActiveCC(dstName, spellName)
@@ -442,9 +434,7 @@ cleuHandler = function()
end
elseif sub == "SPELL_AURA_BROKEN_SPELL" or sub == "SPELL_AURA_BROKEN" then
local _, _, _, _, _, _, _, _, _,
spellId, spellName = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
local spellName = p2
DB:RemoveActiveCC(dstName, spellName)
if Parser.CC[spellName] then
DB:CCBreaker(dstName, spellName, srcName)
@@ -455,9 +445,7 @@ cleuHandler = function()
-- ========================================================================
elseif sub == "SPELL_CAST_SUCCESS" then
local _, _, _, _, _, _, _, _, _,
spellId, spellName = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
local spellName = p2
if Parser.Kicks and Parser.Kicks[spellName] then
DB:RegisterPotentialKick(srcName, spellName, GT())
end
@@ -470,19 +458,13 @@ cleuHandler = function()
-- ========================================================================
elseif sub == "SPELL_INTERRUPT" then
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool,
extraSpellId, extraSpellName = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
extraSpellName = extraSpellName or "Unknown"
local spellName = p2
local extraSpellName = p5
DB:Kick(srcName, dstName, spellName, extraSpellName)
elseif sub == "SPELL_DISPEL" then
local _, _, _, _, _, _, _, _, _,
spellId, spellName, spellSchool,
extraSpellId, extraSpellName = CombatLogGetCurrentEventInfo()
spellName = spellName or "Unknown"
extraSpellName = extraSpellName or "Unknown"
local spellName = p2
local extraSpellName = p5
if isGroupMember(srcName) then
DB:Dispels(srcName, spellName, dstName, extraSpellName)
end