Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF application performance

How to profile a WPF application? I am a beginner C# developer, so I'm sure I would have made some mistakes/bad practices which I should alteast catch by profiling.

Is there a way I can see stack call of all the methods(only ones coded by me, not .NET library functions) and the duration of execution of each method?

like image 993
ns12345 Avatar asked Feb 02 '11 04:02

ns12345


People also ask

Is WPF still relevant 2022?

“WPF would be dead in 2022 because Microsoft doesn't need to be promoting non-mobile and non-cloud technology. But WPF might be alive in that sense if it's the best solution for fulfilling specific customer needs today. Therefore, having a hefty desktop application needs to run on Windows 7 PCs with IE 8.

Is WPF better than WinForms?

The single most important difference between WinForms and WPF is the fact that while WinForms is simply a layer on top of the standard Windows controls (e.g. a TextBox), WPF is built from scratch and doesn't rely on standard Windows controls in almost all situations.

Does WPF use hardware acceleration?

A rendering tier value of 1 or 2 means that most of the graphics features of WPF will use hardware acceleration if the necessary system resources are available and have not been exhausted. This corresponds to a DirectX version that is greater than or equal to 9.0.


2 Answers

Visual Studio includes a great profiling tool:

http://msdn.microsoft.com/en-us/library/z9z62c29.aspx

Another popular profiler for .NET is RedGate ANTS:

http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/

I've found RedGate ANTS easier to setup and use, but in the long run, I had better results with Visual Studio's profiler.

You can see time spent in just your methods, time spent in all methods, CPU time vs Wall time, and other useful metrics.

Just glancing around, this looks like a pretty good tutorial on the profiling tools of Visual Studio: http://www.geekzone.co.nz/vs2008/6265

It's for Visual Studio 2008, but it's the same concepts if you are using VS2010.

Beyond that, your probably need to ask something more specific.

like image 200
mfanto Avatar answered Sep 16 '22 21:09

mfanto


As part of the SDK for Win7 .NET4 there is a profiler tool "The WPF Performance Suite enables you to analyze the run-time behavior of your WPF applications and determine performance optimizations that you can apply. The WPF Performance Suite includes performance profiling tools called Perforator and Visual Profiler"

http://msdn.microsoft.com/en-us/library/aa969767.aspx

like image 26
Jobi Joy Avatar answered Sep 18 '22 21:09

Jobi Joy