morepurplemorebetter / MPMBs-Character-Record-Sheet

MorePurpleMoreBetter's D&D 5e Character Record Sheet
https://www.flapkan.com
GNU General Public License v3.0
372 stars 352 forks source link

A fix for the long wait times generating the spell list #60

Closed adamlynam closed 6 years ago

adamlynam commented 6 years ago

Appears the problem was based on all "Calculate" functions on existing Fields being invoked as a result of each update to the spell list. The fix temporarily disables updates via the app object during the generation of the spell list.

Unfortunately, I am not particularly familiar with the code base, I am not sure if the methods GenerateCompleteSpellSheet and GenerateSpellSheetWithAll should also have this change made to speed them up.

The Adobe documentation suggests that using app.calculate is discouraged in favour of doc.calculate, but I wasn't able to make this work with doc.calculate (which I notice you already appear to try and use too).

Let me know if I can clarify further.

morepurplemorebetter commented 6 years ago

This is great, I could kiss you! I never expected that the app.calculate had any merit as the documentation says it is no longer supported. I had to run some tests because I was in disbelief of how much differences this makes.

I have just spend the last 3 hours rewriting all the places where the code pauses the calculations to do it in a handier way, where a 'master' process (such as spell sheet generation) can prevent any children processes (such as filling the spell description) can restart the calculation.

Now it takes only 17.7 seconds on my PC to generate the full Paladin spell sheet, while before it took 9 minutes and 33.8 seconds!

I will not be merging this pull request because I changed the code around to work in a different way, see the commit, but the use of app.calculate is there.

I have honestly spend way too much time on getting this issue resolved when I first made the spell sheet part and I had fully given up it could be improved. Thank you so much for handing me this solution!

adamlynam commented 6 years ago

No problem. I got so much value out of the sheet, it feels like the least I could do to point you in the direction of a speed up.

I am sorry I wasn't able to give you a solution closer to the major refactor you just did due to my limited knowledge of the codebase. Keep it up!