Admiral-Fish / RaidFinder

Crossplatform RNG tool for Pokemon Sword/Shield raids
GNU General Public License v3.0
179 stars 54 forks source link

stop early if frame compare fails #26

Closed Androidown closed 4 years ago

Androidown commented 4 years ago

In most use cases the shiny filter will be enabled, which means frame comparing is likely to fail when checking the shiny type. It will significantly improve performance if the frame generating loop stops here.

Admiral-Fish commented 4 years ago

What does significantly improve performance mean, did you run any actual benchmarks?

Also I don't think assuming how filters are used is something that can be done practically. Is there any kind of performance penalty in these cases?

Androidown commented 4 years ago

I've wriiten some python scripts with similar function to test the performance differential. One always compares with filter after generating the whole Pokomon data. The other one checks every single Pokemon attribute the time it is determined.

It turns out the second one is about 6 times faster than the first one if shiny filter is enabled.

Sure it'll bring some overhead when filter is disabled. But in these cases, the "max_results" is not supposed to be large and the whole searching process will finish in a second, thus we don't need to care about the performance.

Admiral-Fish commented 4 years ago

So I did some extra testing myself including a hybrid between the current code and your PR. Basically what I did was include the early shiny filter but then leave the compareFrame method at the end but modified to exclude the shiny check since it was already done.

Here are the results running 100000000 frames (time listed in milliseconds): No filters selected: original: 5650 5728 5656 => 5678 androidown: 6291 6298 6264 => 6284.33 (1.1067864271457085828343313373253‬ times slower) fish : 5702 5712 5691 => 5701.66 (1.0041681343195961019138194199836‬ times slower)

Star/Square filter selected: original: 5074 5001 4903 => 4992.66 androidown: 1115 1107 1110 => 1110.66 (4.4951980792316926770708283313327‬ times faster) fish: 1175 1141 1157 => 1157.66 (4.3126979556579326230924272962858 times faster)

What do you think?