-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selectors performance gap #163
Comments
Sergey! You could specify the list of finders you want to use here: https://github.com/lefthandedgoat/canopy/blob/master/src/canopy/configuration.fs#L21 If the app only uses css selectors just make the list have only css. Another way, which they way I think you are suggestion is to allow a 'hint' to tell canopy to not try all selectors because the provided selector is a css/xpath/etc selector Instead of: Number 2 sound reasonable? Option three I guess would be to allow the By.CssSelector syntax like so: |
Personally i like syntax css "#country" << "Germany" Is it possible to analyze selector string and identify type of selector? |
I could do that, but its possible to get it wrong i would think. I could try the guess 2-3 times and then fall back to the full list of selectors. Do you think that is a reasonable compromise? |
Do you know frequency of use non- We can prepare two OOTB modes:
And mention in documentations that configuration.useAllFilders <- true Also you could setup custom list of finders using Does it sound reasonable? |
I know that I use 5 of the 6 heavily. I will think on some of this tomorrow and some bench marking of various solutions. |
I made some optimizations on branch performance-163: 6202a0d Test code:
Results for 1750 runs: Right now both optimizations are on by default and will fall back to old behavior for reliable finds if it fails with optimizations 3 times What are your thoughts? |
I've been thinking more about this. I am concerned that the solution I have has the potential to cause more problems than it solves, especially until the definitions of checking to see if something is a certain type of selector are better. Maybe just adding ability to specify the type of selector is best. The case canopy-2048 has where you are expecting the element to not be there in 99.9% of cases is kind of an edge case. Definitely want to improve it though.
I do think the ability to turn iFrame attempts off is good, so people can turn it off if they know that their app has no iFrames Still thinking on this one =) |
Sounds interesting... My |
Yah a page about performance/configuration would be good. I will look at your project tonight. Thanks! |
Ok cool, definite difference between the two on yours. Mathias Canopy2048 (not dojo) is using a slower more complex algorithm so checking win/loss is not as obvious. With the algorithm you are using its much more obvious. Good find. I will continue to think on it and try to implement explicit hints tomorrow. I think I can also make it faster by turning off the logging that is used for coverage report too. |
Sergey, I finally came up with a solution, which while not properly functional (due to mutable global, I've already messed up with a global browser etc), was easy to implement and works well: Basically I added 2 new flags:
I also added some helpers to that will register a string as using a specific finder. You can see those in canopy.fs lines 780-786 and usage at 213 I manually built this dll and dropped it in to my nuget package canopy folder for Dojo-Canopy-20048 and made these changes: lefthandedgoat/Dojo-Canopy-2048@ee3d6ba The css hint gives the performance like the change you made, and the other flags being turned on helped a little too. Give me your thoughts. If this is a reasonable enough solution I will do a new nuget build and get it out into the wild! |
I like the idea, but in some cases it can lead to unexpected behavior in some cases (see my comments on the code) |
Your improvement ideas are good, and yes an additional page about performance is a good. |
Sergey, I made the changes you suggested, all good ideas: bf6efe4 These for the dojo: let me know what you think. |
Cool, my goal is to have a new build out tonight. Would you like to send a PR to Mathias for the Dojo or want me to? |
I think that this improvement is your merit, so PR is yours ;) |
Done and published. I am also sending a PR to the dojo for Mathias! Thanks Sergey!!! |
Thank you! |
Today we had Dojo-Canopy-2048 in Minsk (Thanks to @mathias-brandewinder for the fun) and have faced with interesting behavior of our bot.
When we add calls to
lost()
andwon()
functions in Interactions.fs performance of emulation is dramatically going down.We profiled our app and have found that the reason is in canopy selectors. On each game loop iteration we are trying to check existence of UI elements that are not exist until the end of the game.
Since
canopy
does not know format of selector, you need to try all one by one until the end ofdefaultFinders
seq. But elements do not exist and all finders return nothing. Nevertheless, you need to run all finders on each call.On the other hand, when you use
Selenium
you can specify kind of selector that you use. So the following code snippet works dramatically faster (but it is not idiomaticcanopy
):I think that
canopy
should provide and API to specify kind of selector and allow users to have performance comparable withSelenium
code.The text was updated successfully, but these errors were encountered: