Skip to content
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

Change UIA backend to use RawViewWalker instead of FindAll #1001

Merged
merged 12 commits into from
Nov 4, 2020

Conversation

eltimen
Copy link
Contributor

@eltimen eltimen commented Oct 29, 2020

Methods children() and descendants() of the UIAElementInfo changed to use IUIAutomation::RawViewWalker instead of IUIAutomationElement::FindAll.

This allows to find more elements than FindAll returns (for example, solves the problem mentioned in #644)

Related issues #644 #696

@eltimen
Copy link
Contributor Author

eltimen commented Oct 29, 2020

I tried to compare the performance of both methods and got the following results:

Test application: modified widgets\mainwindows\mainwindow example from Qt5 with number of dock windows and nested groupboxes specified via command line arguments

Window with 7 children elements, average tree depth 2

Function FindAll median time (seconds) UIA median time (seconds)
children() 0.115 0.191
descendants(depth=3) 0.699 0.297
descendants() 0.211 0.390

Window with 12 children elements, average tree depth 7

Function FindAll median time (seconds) UIA median time (seconds)
children() 0.113 0.220
descendants(depth=3) 0.979 0.329
descendants() 0.217 0.774

Window with 67 children elements, average tree depth 62

Function FindAll median time (seconds) UIA median time (seconds)
children() 0.127 0.367
descendants(depth=3) 22.766 1.285
descendants() 3.384 74.173

Source of used benchmarks located here

@codecov
Copy link

codecov bot commented Oct 29, 2020

Codecov Report

Merging #1001 into atspi will decrease coverage by 5.85%.
The diff coverage is 93.47%.

@@            Coverage Diff             @@
##            atspi    #1001      +/-   ##
==========================================
- Coverage   95.06%   89.20%   -5.86%     
==========================================
  Files          58       58              
  Lines       22100    22037      -63     
==========================================
- Hits        21009    19659    -1350     
- Misses       1091     2378    +1287     

Copy link
Contributor

@airelil airelil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix. I just had a quick go through.

pywinauto/windows/uia_element_info.py Outdated Show resolved Hide resolved
pywinauto/windows/uia_element_info.py Outdated Show resolved Hide resolved
pywinauto/windows/uia_element_info.py Outdated Show resolved Hide resolved
pywinauto/windows/uia_element_info.py Show resolved Hide resolved
pywinauto/windows/uia_element_info.py Outdated Show resolved Hide resolved
pywinauto/windows/uia_element_info.py Outdated Show resolved Hide resolved
pywinauto/unittests/test_uiawrapper.py Outdated Show resolved Hide resolved
@vasily-v-ryabov
Copy link
Contributor

@eltimen thanks for measurements! Please create a Wiki page with these numbers and put a link on it here.

@eltimen
Copy link
Contributor Author

eltimen commented Nov 1, 2020

@eltimen thanks for measurements! Please create a Wiki page with these numbers and put a link on it here.

https://github.com/pywinauto/pywinauto/wiki/Performance-measurements-(draft)

@vasily-v-ryabov vasily-v-ryabov merged commit 5235ee6 into pywinauto:atspi Nov 4, 2020
@eltimen eltimen deleted the uia-raw-tree-walker branch November 4, 2020 08:54
junkmd added a commit to junkmd/pywinauto that referenced this pull request Sep 19, 2023
In pywinauto#207, the `cache_enable` argument was added to the
constructor, propagating to `children` and `descendants`. However, when
`iter_children` and `iter_descendants` were introduced in
pywinauto#475, `cache_enable` wasn't implemented to propagate.

From reviewing past issues and PRs, it appears that not propagating
`cache_enable` was unintentional and simply overlooked.
pywinauto#1001 and pywinauto#1012 refactored the
code without changing the current behavior, resulting in a complex
conditional implementation.
junkmd added a commit to junkmd/pywinauto that referenced this pull request Sep 19, 2023
In pywinauto#207, the `cache_enable` argument was added to the
constructor, propagating to `children` and `descendants`. However, when
`iter_children` and `iter_descendants` were introduced in
pywinauto#475, `cache_enable` wasn't implemented to propagate.

From reviewing past issues and PRs, it appears that not propagating
`cache_enable` was unintentional and simply overlooked.
pywinauto#1001 and pywinauto#1012 refactored the
code without changing the current behavior, resulting in a complex
conditional implementation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants