This project is read-only.

Troubleshooting Slow Performance

Oct 15, 2008 at 6:26 PM
Edited Oct 15, 2008 at 6:33 PM
White looks like it can really fill a great need in supplementing my unit tests. However, I've almost given up on using it since things run slowly for my application.

For example, doing a simple "menu.SubMenu("About")" can take 2.5 - 3 seconds.
Getting top level menus might take 4-5 seconds.
Obtaining all 125 characters from a .NET textbox (MultilineTextBox in White) takes 12.5 seconds. (var licenses = aboutWindow.Get<MultilineTextBox>(SearchCriteria.ByAutomationId("_TextBoxLicenses"));  var licenseText = licenses.Text;)

Additionally, the CPU core that the test is running on is at 100% utilization during this time.

I'm holding out hope that I'm just misunderstanding something and can get it to go faster. I have a basic Winforms app that has a menu and the White test is clicking Help*About and checking the contents of the about box.

I'm pretty sure I don't have that many controls or handles that are getting in the way.

Is this type of performance normal? Any suggestions for how to debug this performance problem? I'm expecting performance similar to a user clicking on menus/buttons.


Oct 18, 2008 at 9:09 AM
Have you read this:

Fetching of UIItems is what takes time. Once they are fetched, the operations on them don't take that long. The above approach works for most of the things except menu/context menu.
Let me know how that goes for you.
Oct 20, 2008 at 8:54 PM
I went ahead and tried the items mentioned in the link you mentioned. I now get a MainWindow.xml file with indices cached. However, there only seemed to be a slight speedup in SubMenu accesses. Even trivial things like getting a very small amount of text from a textbox seems to take 12-20 seconds:

var sw = Stopwatch.StartNew();
var licenses = aboutWindowGuess.Get<MultilineTextBox>(SearchCriteria.ByAutomationId("_TextBoxLicenses"));
var licenseText = licenses.Text;
var timeTotal = sw.ElapsedMilliseconds;

Any other suggestions that might help?

Many thanks!

Oct 22, 2008 at 3:14 AM
I would need some more help from you.
1. Can you let me know if getting the text take 12-20 secs or getting the Multilinetextbox? You can move the sw.ElapsedMilliseconds to check this.
2. Is this the problem when running the test first time or even second time onwards. I would need to see how you are getting the window object.
Oct 22, 2008 at 5:55 PM
var sw = Stopwatch.StartNew();
var licenses = aboutWindowGuess.Get<MultilineTextBox>(SearchCriteria.ByAutomationId("_TextBoxLicenses"));
var justTextBox = sw.ElapsedMilliseconds;
var licenseText = licenses.Text;
var gettingText = sw.ElapsedMilliseconds - justTextBox;

justTextBox = 5781 = 5.7 seconds
gettingText = 12212 = 12.2 seconds

This is happening every time. The times change +- 1 second.

I'm currently getting the window like this:

var allWindows = e.Application.GetWindows();
var aboutWindowGuess = allWindows[1];

I did do:

var aboutWindow = e.Application.GetWindow(SearchCriteria.ByAutomationId("AboutDialog"), InitializeOption.NoCache);

but that didn't seem to work, even though UISpy reported the automationid of the dialog to be AboutDialog.

Thanks for the continued follow-up!
Oct 25, 2008 at 8:44 PM
But getting textbox should become faster (from second time onwards) if you change the code to get the window....
var aboutWindow = e.Application.GetWindow(SearchCriteria.ByAutomationId("AboutDialog"), InitializeOption.NoCache.AndIdentifiedBy("foo"));

I am bit puzzled about why getting text is taking time. Can you run MultilineTextbox unit tests which come with white source to see if that also gives the same kind of performance.