majikat768 / HuntStatsLogger

stats logger for Hunt: Showdown
MIT License
62 stars 7 forks source link

performance improvement #81

Closed maxpwr46 closed 9 months ago

maxpwr46 commented 11 months ago

Hi,

I am aproaching 1000 logged hunts (889 to be precise) and slowly but surely I got dissatisfied with the boot up time of the app. It turns out that the way the number of kills for each match in the dropdown box was calculated had a massive impact on the performance. It got calculated by a single query for each match which scales really poorly. With this PR the kills get pulled from the DB with a single query along all the other info that is retrieved anyway.

As I changed the returned columns of GetHunts() please have a carefull look if that is fine for all the callers. I only found the location I made the change for and a call in MyTeams.py. The latter only cares about the timestamp and should be fine.

I did some poor mans performance measurements by commenting out everything from mainUpdate() in MainFrame.py except self.huntsTab.update() to somewhat isolate the changes I made. By hand, I then just measured the time it takes for the main window to come up. Drumroll... I got it from roughly 15s down to about 2s so the difference is massive.

The second biggest culprit is the teams tab but I haven't looked into it.

timpatullock commented 9 months ago

Code reads fine on my end, only note is that the dict(zip()) needs some manual look-up from another user to double-check what it does. Nice!

majikat768 commented 9 months ago

Thanks! I agree, both the KDA and the teams calculation can be vastly improved. I've been working on optimizing those just recently, I have a new algorithm for the teams which should help a lot.

timpatullock commented 9 months ago

Just checking in here, should we merge this @majikat768