Why the difference in search times?

Ask general questions here.
User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Why the difference in search times?

Post by Ciege » Wed Feb 17, 2010 10:09 pm

With the following two lines of code why the difference in search times?

#1

Code: Select all

Ranorex.Table HDTable = HDReportsForm.FindSingle(".//element[@controlname='gridItems']/table[@accessiblerole='Table']", 180000);
#2

Code: Select all

Ranorex.Table HDTable2 = HDReportsForm.FindSingle(".//table[@accessiblerole='Table']", 180000);
All things being equal,
#1 routinely takes around 2 minutes to find the table in my AUT.
#2 routinely takes less than 20 seconds to find the table in my AUT.



Similarly, if I do this, the element and table are usually found in less than 20 seconds.

Code: Select all

Ranorex.Core.Element HDElement = HDReportsForm.FindSingle(".//element[@controlname='gridItems']", 180000);
Ranorex.Table HDTable = HDElement.FindSingle(".//table[@accessiblerole='Table']", 180000);
Thanks!
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Why the difference in search times?

Post by Support Team » Tue Feb 23, 2010 4:08 pm

hey Ciege,

Sorry for the late answer.

Searching for
".//element[@controlname='gridItems']/table[@accessiblerole='Table']"
looks through *everything* for the element with controlname gridItems, and then looks beneath for the matching table. If one is found, the search is complete.

Splitting it up (like you do in the last sample), causes the search for the gridItems element to be finished after a single matching element has been found.

This behavior is caused by the fact that the steps in the RxPath match a set of items, not only a single item, and the "FindSingle" optimizes only the last step, because there might be different "gridItem" elements somewhere...

There is currently room for improvement, so stay tuned :D

Generally, "//" should be used with great care because this is usually very expensive. So splitting up the search if you are looking for a single element with "//" is a really good idea (if "//" is not the last step in the search)

Michael
Ranorex Team
.
Image