How do I make this options list faster?
To repeat this just download GalvinUnitBars from curse:
https://wow.curseforge.com/projects/.../files/2710572 Then go to general -> Alt Power Bar Make sure "Show used bars only" is unchecked The problem is each time I leave this options window and go back. The same lag happens. I'd like to know how I can speed this up. Code:
local function BuildAltPowerBarList(APA, Order, Name, TableName) |
Lua Code:
This is most likely the source of the lag and completely unnecessary. I’m assuming the bar IDs include any displayed bars for raid members. This means that the maximum amount of available alt power bars at once should be 80, assuming a complicated encounter with two bars and a full raid of 40. Realistically, the maximum is 50. If you want to play it safe, reduce that 10000 to 99. |
Its not for a raid. Its an options list to pick which alternate powerbars you want to use. If the user checks one off. It uses blizzards own artwork instead. Otherwise it uses a statusbar to show it.
Its not creating 10000 objects. So that part isn't effecting anything. Its creating as many powerbars as it finds. |
That code is literally doing 10,000 function calls, 10,000-40,000 concatenates. Nearly 100,000 if checks and 100,000 table look ups. It doesn't matter how many options they've set, there's no check for that. As written, that code does that for loop 10,000 times. The very first line alone within it will cause 10,000 function runs via GetAlternateInfoByID()
I'd bet a lot of money that's where your lag is coming from |
No, you underestimate how fast lua runs. I'd have to set it to a million something before you'd notice lag.
I did change it to a 1000, but it didn't change anything in terms of lag. What's causing the lag is building the objects. On PTR this is even worse, it lags around 10x It's not the problem |
Quote:
|
Use what SDPhantom said to dissuade everyone.
Personally I'd use more tables than concatenations since memory references take both CPU cycles and RAM, it can actually take less time just to use an extra CPU cycle. Lua Code:
Scope helps, creating new locals every single time in a loop creates them that many times. And garbage collection isn't guaranteed to work immediately after the function is resolved. Lua Code:
Making If statements with a common denominator helps Lua Code:
|
Quote:
|
The overhead of creating objects in ace3 is pretty high on the PTR. On live it creates some lag but only 1.5seconds. And since its out of combat stuff. Don't think people will mind it much.
Yeah I already cut the loop down to 1000 iterations. There's only around 200 alternate power bars total. Underscores are already localized. Everything is localized if possible. The actually amount of work going on is around 200 bars. That's not much work at all. The lag is coming from making the objects in ace3. Here a video showing what I'm doing. All this stuff works on live. But on PTR those lag spikes are 15 to 20seconds long. https://www.youtube.com/watch?v=RZ1f2QBqojk |
Update the code, still runs dog slow on 8.2 PTR, takes around 1 second on live and 15+ on PTR. Fast as I can make it
Code:
local function BuildAltPowerBarList(APA, Order, Name, TableName) |
All times are GMT -6. The time now is 06:23 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI