Describe the bug
High resource usage/inefficient API calls
To Reproduce
Steps to reproduce the behavior:
Just playing the game even idle.
Addon version (please complete the following information):
Additional context
I've noticed lots of fps stutters in my game and done a few addon performance measurements, your addon (among few others) was shown to generate a lot of cpu usage even when doing nothing.
Here's a performance assessment report, maybe it can help you identify some issues or improve the addon's performance:
Accountant Performance Report
Version: 11.1.0 | Reviewed against: WoW 12.0.1
---
1. No debouncing on PLAYER_MONEY (lines 1943-1946)
Every gold change calls UpdateLog() + LDB_Update() immediately. LDB_Update() runs GetDetailForToons() and GetCashForToons() twice each (lines 801-838), both looping 15 categories x N
characters with regex matching. Nothing batches rapid gold changes. During fast vendor selling or AH operations this fires many times per second, and the cost scales linearly with the number
of characters stored in SavedVariables.
Suggested fix: Debounce with C_Timer.After(0.1, ...) to coalesce rapid PLAYER_MONEY events into a single update.
2. Duplicate LDB_Update when window is visible (lines 1946 + 2336->2256)
When the window is open, UpdateLog() calls OnShow() (line 2336), which calls LDB_Update() (line 2256). Then the PLAYER_MONEY handler calls LDB_Update() again (line 1946). Same work runs
twice for no reason. Low impact for single-character players, but compounds with issue #1 for players with many alts.
Suggested fix: Guard line 1946 with "if not AccountantFrame:IsVisible() then SC:LDB_Update() end".
3. Wasted API call in GetCashForToons (line 2105)
C_Bank.FetchDepositedMoney(2) is called and stored in warbandBankBalance, but that variable is never referenced in the function. This runs 2-5 times per PLAYER_MONEY event.
Suggested fix: Delete line 2105.
4. ACCOUNT_MONEY nil crash (line 1938)
SC.bankwarbandcash and SC.bankcash are only set when BANKFRAME_OPENED fires (lines 1915-1916) and are never initialized. ACCOUNT_MONEY can fire without the bank open (Blizzard's MoneyFrame
registers it globally). When it does, line 1938 hits nil - number and errors.
Suggested fix: Initialize SC.bankcash = 0 and SC.bankwarbandcash = 0 at the top of the file (near line 33), or wrap the ACCOUNT_MONEY block in "if SC.bankopened then".
5. Global variable leaks in hot paths
Several variables are written without "local", polluting _G on every gold change: diff (UpdateLog, line 2288), cash (LDB_Update, line 804), TotalWarband (ShowValues, line 2194), TotalIn and
TotalOut (ShowValues, lines 2198-2199), postage (UpdateLog, line 2316).
Suggested fix: Add "local" to each.
---
API compliance: All APIs used by the addon are valid in 12.0.1. No deprecated calls found.
Describe the bug
High resource usage/inefficient API calls
To Reproduce
Steps to reproduce the behavior:
Just playing the game even idle.
Addon version (please complete the following information):
Additional context
I've noticed lots of fps stutters in my game and done a few addon performance measurements, your addon (among few others) was shown to generate a lot of cpu usage even when doing nothing.
Here's a performance assessment report, maybe it can help you identify some issues or improve the addon's performance: