toddrob99 / MLB-StatsAPI

Python wrapper for MLB Stats API
GNU General Public License v3.0
539 stars 100 forks source link

Split search input by word #143

Open ap-ack opened 3 months ago

ap-ack commented 3 months ago

138

toddrob99 commented 1 month ago

Are you able to provide some timing comparisons, to see how much performance is impacted by this change? With the way you did it, I'm guessing it's minimal.

ap-ack commented 1 month ago

I measured my code as consistently running 1-2 ms slower than yours, even for single-word search inputs where we couldn't attribute this difference to the algorithm change. So I tried replacing the all/any functions with for-else loops, which to my surprise measured 1-2 ms faster than the existing code, even for multi-word cases. So I pushed that optimization.

Findings attached and as noted, this measures only the search so negates the network call latency, which far outweighs the search anyway.

stats-lookup-analysis.xlsx