Why the difference in search times? : General Questions

Why the difference in search times?

Ask general questions here.

Why the difference in search times?

Postby Ciege » Wed Feb 17, 2010 11: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
Ciege
 
Posts: 455
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: Why the difference in search times?

Postby Support Team » Tue Feb 23, 2010 5: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
User avatar
Support Team
Site Admin
 
Posts: 2015
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to General Questions

Who is online

Users browsing this forum: No registered users and 0 guests