Skip to content

Commit

Permalink
Expose current action list in virtual state; update performance thing…
Browse files Browse the repository at this point in the history
…s and stuff.
  • Loading branch information
Hekili committed Nov 19, 2024
1 parent 2287df3 commit a3682d8
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 8 deletions.
9 changes: 9 additions & 0 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ function Hekili:GetPredictionFromAPL( dispName, packName, listName, slot, action
local action = entry.action

state.this_action = action
state.this_list = listName
state.delay = nil

local ability = class.abilities[ action ]
Expand All @@ -780,12 +781,14 @@ function Hekili:GetPredictionFromAPL( dispName, packName, listName, slot, action
action = class.active_essence
ability = class.abilities[ action ]
state.this_action = action
state.this_list = listName
entryReplaced = true
elseif action == "trinket1" then
if state.trinket.t1.usable and state.trinket.t1.ability and not Hekili:IsItemScripted( state.trinket.t1.ability, true ) then
action = state.trinket.t1.ability
ability = class.abilities[ action ]
state.this_action = action
state.this_list = listName
entryReplaced = true
else
if debug then
Expand All @@ -798,6 +801,7 @@ function Hekili:GetPredictionFromAPL( dispName, packName, listName, slot, action
action = state.trinket.t2.ability
ability = class.abilities[ action ]
state.this_action = action
state.this_list = listName
entryReplaced = true
else
if debug then
Expand All @@ -809,6 +813,7 @@ function Hekili:GetPredictionFromAPL( dispName, packName, listName, slot, action
action = class.abilities[ action ].key
ability = class.abilities[ action ]
state.this_action = action
state.this_list = listName
entryReplaced = true
elseif action == "potion" then
local usePotion = entry.potion or spec.potion
Expand All @@ -819,10 +824,12 @@ function Hekili:GetPredictionFromAPL( dispName, packName, listName, slot, action
action = nil
ability = nil
state.this_action = "wait"
state.this_list = listName
else
action = class.abilities[ usePotion ] and class.abilities[ usePotion ].key or "tempered_potion"
ability = class.abilities[ action ]
state.this_action = action
state.this_list = listName
entryReplaced = true
end
end
Expand Down Expand Up @@ -1429,6 +1436,7 @@ function Hekili:GetNextPrediction( dispName, packName, slot )
local action, wait, depth = nil, 10, 0

state.this_action = nil
state.this_list = nil

state.selection_time = 10
state.selected_action = nil
Expand Down Expand Up @@ -1947,6 +1955,7 @@ function Hekili.Update( initial )
if i < display.numIcons then
-- Advance through the wait time.
state.this_action = action
state.this_list = listName

if state.delay > 0 then state.advance( state.delay ) end

Expand Down
20 changes: 18 additions & 2 deletions Hekili.lua
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,11 @@ function Hekili:SaveDebugSnapshot( dispName )

-- Store previous spell data.
local prevString = "\nprevious_spells:"

-- Skip over the actions in the "prev" table that were added to computed the next recommended ability in the queue.
local i, j = ( #state.predictions + 1 ), 1
local spell = state.prev[i].spell or "no_action"

if spell == "no_action" then
prevString = prevString .. " no history available"
else
Expand Down Expand Up @@ -307,7 +309,6 @@ function Hekili:SaveDebugSnapshot( dispName )
auraString = format( "%s\n %6d - %-40s - %3d - %-6.2f", auraString, spellId, key or ( "*" .. formatKey( name ) ), count > 0 and count or 1, expirationTime > 0 and ( expirationTime - now ) or 3600 )
end


if not UnitExists( "target" ) then
auraString = auraString .. "\n\ntarget_auras: target does not exist"
else
Expand Down Expand Up @@ -344,11 +345,26 @@ function Hekili:SaveDebugSnapshot( dispName )
insert( v.log, 1, "targets: " .. ( Hekili.TargetDebug or "no data" ) )
insert( v.log, 1, self:GenerateProfile() )


local performance
local pInfo = HekiliEngine.threadUpdates

-- TODO: Include # of active displays, number of icons displayed.

if pInfo then
performance = string.format( "\n\nPerformance\n"
.. "|| Updates || Updates / sec || Avg. Work || Avg. Time || Avg. Frames || Peak Work || Peak Time || Peak Frames || FPS || Work Cap ||\n"
.. "|| %7d || %13.2f || %9.2f || %9.2f || %11.2f || %9.2f || %9.2f || %11.2f || %3d || %8.2f ||",
pInfo.updates, pInfo.updatesPerSec, pInfo.meanWorkTime, pInfo.meanClockTime, pInfo.meanFrames, pInfo.peakWorkTime, pInfo.peakClockTime, pInfo.peakFrames, GetFramerate() or 0, Hekili.maxFrameTime or 0 )
end

if performance then insert( v.log, performance ) end

local custom = ""

local pack = self.DB.profile.packs[ state.system.packName ]
if not pack.builtIn then
custom = format( " |cFFFFA700(Custom: %s[%d])|r", state.spec.name, state.spec.id )
custom = format( " |cFFFFA700(*%s[%d])|r", state.spec.name, state.spec.id )
end

local overview = format( "%s%s; %s|r", state.system.packName, custom, dispName or state.display )
Expand Down
17 changes: 16 additions & 1 deletion Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6043,7 +6043,15 @@ found = true end
vroom = {
type = "header",
name = function()
return format( "VR%sM!", string.rep( "O", self.DB.profile.specs[ id ].placeboBar or 5 ) )
local amount = self.DB.profile.specs[ id ].placeboBar or 5

if amount > 19 then
return "|cFFFF0000MAXIMAL VROOM|r - Secret Optimal Mode Unlocked"
elseif amount > 14 then
return "|cFFFF0000DANGER|r - Approaching Maximum VROOOM"
end

return format( "VR%sM!", string.rep( "O", amount ) )
end,
order = 101,
width = "full"
Expand Down Expand Up @@ -7810,6 +7818,8 @@ n = tonumber( n ) + 1

-- Let's load variables, just in case.
for name, alist in pairs( apack.lists ) do
state.this_list = name

for i, entry in ipairs( alist ) do
if name ~= list or i ~= action then
if entry.action == "variable" and entry.var_name then
Expand All @@ -7823,6 +7833,7 @@ n = tonumber( n ) + 1
entry = entry and entry[ action ]

state.this_action = entry.action
state.this_list = list

local scriptID = pack .. ":" .. list .. ":" .. action
state.scriptID = scriptID
Expand Down Expand Up @@ -7850,6 +7861,7 @@ n = tonumber( n ) + 1

-- Let's load variables, just in case.
for name, alist in pairs( apack.lists ) do
state.this_list = name
for i, entry in ipairs( alist ) do
if name ~= list or i ~= action then
if entry.action == "variable" and entry.var_name then
Expand All @@ -7863,6 +7875,7 @@ n = tonumber( n ) + 1
entry = entry and entry[ action ]

state.this_action = entry.action
state.this_list = list

local scriptID = pack .. ":" .. list .. ":" .. action
state.scriptID = scriptID
Expand Down Expand Up @@ -7894,6 +7907,7 @@ n = tonumber( n ) + 1

-- Let's load variables, just in case.
for name, alist in pairs( apack.lists ) do
state.this_list = name
for i, entry in ipairs( alist ) do
if name ~= list or i ~= action then
if entry.action == "variable" and entry.var_name then
Expand All @@ -7907,6 +7921,7 @@ n = tonumber( n ) + 1
entry = entry and entry[ action ]

state.this_action = entry.action
state.this_list = list

local scriptID = pack .. ":" .. list .. ":" .. action
state.scriptID = scriptID
Expand Down
5 changes: 4 additions & 1 deletion Scripts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,7 @@ local function ConvertScript( node, hasModifiers, header )
state.scriptID = header

state.this_action = node.action
state.this_list = header:match( "^(.-):" ) or "default"

local t = node.criteria and node.criteria ~= "" and node.criteria
local clean = SimToLua( t )
Expand Down Expand Up @@ -1502,7 +1503,9 @@ scripts.ConvertScript = ConvertScript

function scripts:CheckScript( scriptID, action, elem )
local prev_action = state.this_action
if action then state.this_action = action end
if action then
state.this_action = action
end

local script = self.DB[ scriptID ]

Expand Down
2 changes: 2 additions & 0 deletions State.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,7 @@ do
selection = 1,
selection_time = 1,
this_action = 1,
this_list = 1,

-- Calculated from event data.
aggro = 1,
Expand Down Expand Up @@ -2066,6 +2067,7 @@ do
elseif k == "selection" then return t.selection_time < 60
elseif k == "selection_time" then t[k] = 60
elseif k == "this_action" then t[k] = "wait"
elseif k == "this_list" then t[k] = "default"

-- Calculated from real event data.
elseif k == "aggro" then t[k] = ( UnitThreatSituation( "player" ) or 0 ) > 1
Expand Down
36 changes: 32 additions & 4 deletions UI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2332,14 +2332,42 @@ do
self.activeThreadFrames = 0

if not self.firstThreadCompleted then
Hekili.maxFrameTime = InCombatLockdown() and 10 or 50
Hekili.maxFrameTime = 16.67
else
local spf = GetFramerate()
spf = 950 / ( spf > 0 and spf or 60 )
local rate = GetFramerate()
local spf = 1000 / ( rate > 0 and rate or 60 )

if HekiliEngine.threadUpdates then
Hekili.maxFrameTime = min( spf, HekiliEngine.threadUpdates.meanFrameTime )

--[[ local mode = Hekili:GetActiveSpecOption( "updateMode" ) or "auto"
if mode == "auto" then
-- Adjust throttle to 90% of frame time vs. time spent in thread; constrained to range of 60 to ~144 FPS.
Hekili.maxFrameTime = max( 7, min( 16.67, 0.9 * HekiliEngine.threadUpdates.meanClockTime / HekiliEngine.threadUpdates.meanFrames ) )
elseif mode == "percent" then
local percent = Hekili:GetActiveSpecOption( "updatePercent" ) or 0.9
-- Adjust throttle to X% of current frame rate, constrained to range of 30 to 200 FPS.
Hekili.maxFrameTime = max( 5, min( 33.33, spf * percent ) )
elseif mode == "scaled" then
local lowFrame = 1000 / ( Hekili:GetActiveSpecOption( "lowFPS" ) or 30 )
local lowPercent = Hekili:GetActiveSpecOption( "lowPercent" ) or 0.5
local highFrame = 1000 / ( Hekili:GetActiveSpecOption( "highFPS" ) or 200 )
local highPercent = Hekili:GetActiveSpecOption( "highPercent" ) or 0.9
-- Adjust throttle to X percent of current frame rate, scaled linearly from lowFPS to highFPS.
if rate < lowFrame then spf = lowPercent * lowFrame
elseif rate > highFrame then spf = highPercent * highFrame
else spf = lowPercent + ( rate - lowFrame ) * ( highPercent - lowPercent ) / ( highFrame - lowFrame ) end
spf = min( 33.33 * ercent, min( ) )
local maxPercent = Hekili:GetActiveSpecOption( "maxPercent" ) or 0.9
local minPercent = Hekili:GetActiveSpecOption( "minPercent" ) or 0.5
... ]]
else
Hekili.maxFrameTime = spf
Hekili.maxFrameTime = max( 7, min( 16.67, 0.9 * spf ) )
end
end

Expand Down

0 comments on commit a3682d8

Please sign in to comment.