Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AutomationElement.FindAll() performance issue

We have been working with the MS UIA framework and noticed what appears to be a significant slowdown when finding collections of objects in Windows 10 / .NET 4.6.

When testing AutomationElement.FindAll() on a Windows 10 / .NET 4.6 box our times on average are roughly 3 to 5 times longer to find collections of elements than when finding the exact same elements on a Windows 8.1 / .NET 4.5.1 box. My test is against a WPF DataGrid with virtualization on (using Recycling) and getting all of the cells inside each row of the DataGrid.

On our Win10 box each FindAll call to get the cells in each row takes roughly 30 - 50ms or even longer. On the Win8.1 box it takes around 5 - 10ms. I am unable to figure out why, but I do not think the issue is limited to the DataGrid since there is nothing fancy about our FindAll() call.

        //get grid
    AutomationElement gridElement = AutomationElement.RootElement.FindFirst(TreeScope.Descendants,
           new PropertyCondition(AutomationElement.AutomationIdProperty, "dataGridAutomationId"));

    //get all visible rows
    AutomationElementCollection dataItems = gridElement.FindAll(TreeScope.Descendants,
                       new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataItem));

 foreach (AutomationElement dataItem in dataItems)
 {
    if (!string.IsNullOrEmpty(dataItem.Current.Name))
    {
        //call under test
        AutomationElementCollection cells = dataItem.FindAll(TreeScope.Children,
             new PropertyCondition(AutomationElement.ClassNameProperty, "DataGridCell"));
    }
 }

The use of AutomationElement.RootElement is for the test only. The 'dataItem.FindAll()' call is what I am testing.

Win 8.1 and Win10 machine specs:

  • Xeon W3670 3.20GHz cpu
  • 12gb ram
  • 64bit OS

We have tried using the unmanaged MS uia API via com wrapping and saw no noticeable performance improvements on Win10.

Any advice would be much appreciated.

like image 701
Jordan Avatar asked Oct 06 '15 12:10

Jordan


1 Answers

This appears to have been fixed in the latest round of Windows 10 updates (kb/3093266). According to an MS support representative I spoke with:

"UIA was frequently calling the NtQuerySystemInformation, the performance of calling that API frequently is not satisfactory. They made changes to that particular code path and do not call that API anymore and that improved the overall performance."

Unfortunately that was all the information they had so I am unable to determine exactly what about that call was causing the issue.

After updating and testing, performance is the same across both machines.

like image 198
Jordan Avatar answered Sep 28 '22 09:09

Jordan