Module talk:vote table
Add topicAppearance
Latest comment: 8 years ago by Wikitiki89 in topic Performance fix
Performance fix
[edit]@Daniel Carrero: As a learning experience, I would like you to understand how my fix helped. countVotesFullPage
is a fairly expensive function. You were calling not just once for each vote page, but additionally once for each person for each vote page. In other words if p
is the number of people and v
is the number of vote pages, you were actually calling this function v + v * p
times, when you only needed to call it v
times. To illustrate better, if there are 20 voters and 10 vote pages and parsing a vote page with countVotesFullPage
takes 0.1 seconds, your version would spend 21 seconds parsing votes, while my version would spend 1 second. --WikiTiki89 19:53, 9 September 2016 (UTC)
- Thank you very much for fixing the module and explaining how your fix helped. I appreciate it. --Daniel Carrero (talk) 19:56, 9 September 2016 (UTC)
- As one of my professors once told us, (I'm paraphrasing) "Optimization is hard, so don't optimize; just make sure you don't do the same thing twice." --WikiTiki89 20:07, 9 September 2016 (UTC)