开发者

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开发者_如何学C 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.


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


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


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


You should use the event ContentRendered of Window.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜