tullaRange

tullaRange

1M Downloads

Code refactor

Odjur opened this issue ยท 5 comments

commented

I did a code refactor for my own personal use. You're welcome to implement it if you'd like. I unfurled a bunch of nested function calls and made some small changes, improving performance by ~15% with default settings and ~33% at a faster update rate.

tullaRange.zip

commented

Neat, I'll try to look at it next week.

commented

How are you benchmarking this? I want to try and replicate your results.

At the moment I'm getting much higher CPU readings than the main build when checking via Addon Usage. I've limited my framerate to 60 to try and control for that as well.

commented

Well, It would help if I also throttled your updates to the same level.

commented

Thank you. Your changes are implemented in 10.0.6. A few differences:

  • I'm using a ticker instead of an OnUpdate handler. This tends to perform a bit better at lower update frequencies.
  • I'm only grabbing local copies of globals in the main loop. The others aren't really necessary
  • I'm performing an initial access of buttonStates before looping through each button. This saves a lookup on each slot access
  • I refactored to set a state variable, and then use that instead of repeating the SetVertexColor logic
commented

I was using the addon AddonUsage to benchmark. I didn't benchmark individual functions or anything, rather just got a very rough estimate of the average CPU usage. Frankly the CPU usage is trivial when at an update rate of 0.2 anyways.

The OnUpdate handler was added because it performs better when updating every frame, or near every frame, but obviously if you are going to go with a slower rate it makes sense to return to the C functions. It would be possible to switch between the two based on the update rate setting, but maybe that's more work than it's worth.

The state variable is definitely way cleaner than the way I was going about it lol.

Thanks for all your hard work!