Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to measure screen render time in WPF

I am attempting to measure the performance for a WPF based application. Currently we have code that times how long it takes to add the content to the WPF render tree. At this point, control is returned to our program. The problem is that there is still a lag before content is displayed on the screen by WPF. For complicated rendering trees, this can be a matter of seconds.

Can you recommend a method to determine when WPF has completed rendering to the screen? I would like these tests to be fully automated and not rely on someone sitting around with a stopwatch.

[update]

Thanks for the suggestions so far.

I have tried waiting for the Loaded and ContentRendered events, but both fire before the content makes it to the screen.

It looks like others are having this issue. I have tried the steps suggested at http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/693fbedb-efa6-413e-ab66-530c6961d3fb/ but still haven't been able force my code to wait for the rendering to complete.

like image 531
Brian Erickson Avatar asked Mar 31 '11 17:03

Brian Erickson


4 Answers

You may use this solution: http://www.japf.fr/2009/10/measure-rendering-time-in-a-wpf-application/

like image 81
Jonathan ANTOINE Avatar answered Nov 15 '22 22:11

Jonathan ANTOINE


Did you take a look at the WPF Performance suite? You might be able to see the performance and pinpoint problematic code.

like image 32
Emond Avatar answered Nov 15 '22 22:11

Emond


You could end the timer after the control's Loaded event since that occurs after the Rendering is complete.

like image 1
Rachel Avatar answered Nov 16 '22 00:11

Rachel


You should use the event ContentRendered of Window.

This will fire every time there's a full rendering sequence, and you can time that.

like image 1
Elad Katz Avatar answered Nov 15 '22 23:11

Elad Katz