/bs cpu: add clamp on/off test switch, drop frame CPU line
ClassicAPI's frame CPU numbers exceeded wall-clock time, so they are no longer shown. `/bs cpu clamp on|off` toggles SetClampedToScreen on the inventory windows for the session to test the engine-side drag stalls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019W3rwt5PZSpEDkXYzRuRhH
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
### Added
|
||||
|
||||
- `/bs cpu` (hidden command): with ClassicAPI and `/console scriptProfile 1`, shows where CPU time went since the last reset: the busiest addons, Bagshui's windows, and Bagshui's busiest functions. `/bs cpu reset` starts a new measurement.
|
||||
- `/bs cpu` (hidden command): with ClassicAPI and `/console scriptProfile 1`, shows where CPU time went since the last reset: the busiest addons and Bagshui's busiest functions. `/bs cpu reset` starts a new measurement, and `/bs cpu clamp on|off` switches the windows' keep-on-screen clamp until /reload (for testing drag freezes).
|
||||
|
||||
## 1.6.5 - 2026-10-31
|
||||
|
||||
|
||||
+31
-30
@@ -2,8 +2,10 @@
|
||||
-- Exposes: Bagshui.components.CpuProfile
|
||||
--
|
||||
-- `/bs cpu` reads ClassicAPI's script profiler and prints where CPU time went since the last
|
||||
-- reset (or /reload): the busiest addons, Bagshui's busiest frames, and Bagshui's busiest
|
||||
-- functions. `/bs cpu reset` starts a new measurement.
|
||||
-- reset (or /reload): the busiest addons and Bagshui's busiest functions.
|
||||
-- `/bs cpu reset` starts a new measurement.
|
||||
-- `/bs cpu clamp on|off` switches the windows' keep-on-screen clamp for this session only,
|
||||
-- to test whether it causes the engine-side stalls while dragging.
|
||||
--
|
||||
-- Needs ClassicAPI and the scriptProfile CVar (`/console scriptProfile 1`, then /reload).
|
||||
-- Profiling slows every addon down a little, so turn it off again when done.
|
||||
@@ -13,7 +15,6 @@ Bagshui:AddComponent(function()
|
||||
Bagshui.components.CpuProfile = CpuProfile
|
||||
|
||||
local TOP_ADDONS = 5
|
||||
local TOP_FRAMES = 4
|
||||
local TOP_FUNCTIONS = 8
|
||||
|
||||
--- Print one line to chat with a consistent prefix.
|
||||
@@ -60,31 +61,6 @@ Bagshui:AddComponent(function()
|
||||
return list
|
||||
end
|
||||
|
||||
--- CPU time of Bagshui's own frames (scripts on the frame and its children).
|
||||
---@return table list { name, ms }
|
||||
local function FrameUsage()
|
||||
local list = {}
|
||||
if type(_G.GetFrameCPUUsage) ~= "function" then
|
||||
return list
|
||||
end
|
||||
local function Add(name, frame)
|
||||
if frame then
|
||||
local ok, ms = pcall(_G.GetFrameCPUUsage, frame, true)
|
||||
if ok and type(ms) == "number" and ms > 0 then
|
||||
table.insert(list, { name = name, ms = ms })
|
||||
end
|
||||
end
|
||||
end
|
||||
Add("Event frame", Bagshui.eventFrame)
|
||||
for name, component in pairs(Bagshui.components) do
|
||||
if type(component) == "table" and type(component.uiFrame) == "table" then
|
||||
Add(name .. " window", component.uiFrame)
|
||||
end
|
||||
end
|
||||
table.sort(list, ByMs)
|
||||
return list
|
||||
end
|
||||
|
||||
--- CPU time of every function reachable from Bagshui's tables.
|
||||
--- `total` includes the functions it calls; `self` is time spent in the function itself.
|
||||
---@return table byTotal, table bySelf Lists of { name, ms }.
|
||||
@@ -150,7 +126,6 @@ Bagshui:AddComponent(function()
|
||||
Out("CPU time since " .. since .. " (/bs cpu reset to start over)")
|
||||
|
||||
PrintTop("Addons", AddOnUsage(), TOP_ADDONS)
|
||||
PrintTop("Bagshui frames", FrameUsage(), TOP_FRAMES)
|
||||
local byTotal, bySelf = FunctionUsage()
|
||||
PrintTop("Bagshui functions, own time", bySelf, TOP_FUNCTIONS)
|
||||
PrintTop("Bagshui functions, including calls", byTotal, TOP_FUNCTIONS)
|
||||
@@ -167,9 +142,35 @@ Bagshui:AddComponent(function()
|
||||
Out("counters reset. Reproduce the hitch, then type /bs cpu.")
|
||||
end
|
||||
|
||||
--- Switch the keep-on-screen clamp on all inventory windows (not saved; /reload restores it).
|
||||
---@param enable boolean
|
||||
function CpuProfile:SetClamp(enable)
|
||||
local count = 0
|
||||
for _, component in pairs(Bagshui.components) do
|
||||
if
|
||||
type(component) == "table"
|
||||
and component.inventoryType
|
||||
and type(component.uiFrame) == "table"
|
||||
and component.uiFrame.SetClampedToScreen
|
||||
then
|
||||
component.uiFrame:SetClampedToScreen(enable)
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
Out(string.format("keep-on-screen clamp %s for %d windows until /reload.", enable and "ON" or "OFF", count))
|
||||
end
|
||||
|
||||
BsSlash:AddHandler("CPU", function(tokens)
|
||||
if tokens[2] and string.lower(tokens[2]) == "reset" then
|
||||
local verb = tokens[2] and string.lower(tokens[2])
|
||||
if verb == "reset" then
|
||||
CpuProfile:Reset()
|
||||
elseif verb == "clamp" then
|
||||
local state = tokens[3] and string.lower(tokens[3])
|
||||
if state == "on" or state == "off" then
|
||||
CpuProfile:SetClamp(state == "on")
|
||||
else
|
||||
Out("usage: /bs cpu clamp on|off")
|
||||
end
|
||||
else
|
||||
CpuProfile:Report()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user