WPF application performance - c#

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?

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.

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

Related

Is it possible to know how many objects of a type are loaded in Visual Studio 2013

I would like to know if while debugging, is possible to know how many objects of a type are loaded using a Visual Studio 2013. I am currently developing in C#.
It depends on the edition of Visual Studio you're using whether there's native support for this with a nice GUI. The .NET Memory Allocation Profiler can help you view the number of objects in memory, it ships with Visual Studio Premium and Ultimate. You can also use a more hard-core technique using Sons-of-Strike, which can give you very detailed information, should you know what to look for. SoS works with any version of Visual Studio and even with the basic WinDbg debugger. Here's an additional tutorial from the Microsoft P&P group on the subject. To get SoS you need to download and install the Windows Debugging Tools whcih you can find here.
There are a number of 3rd party profilers as well, like:
Red-Gate Ants Memory profiler
JetBrains dotTrace
Intel VTune
SciTech .NET Memory Profiler
Other similar questions on StackOverflow:
What Are Some Good .NET Profilers?
.NET Memory Profiling Tools

Can Visual Studio 2012/2013 professional make (managed/ c#) memory snapshots during profiling?

This is somewhat unclear.
We've been using JetBrains dotTrace Memory for memory profiling in C# before. As the latest version of it supports only .net 3.5 we are pretty stuck.
Can the visual studio profiler make memory snapshots at two distinct times and display the difference?
I am trying to pin down some memory leaks and I seem unable to get close to what causes them
I've read the post about profiling here: http://blogs.msdn.com/b/dotnet/archive/2013/04/04/net-memory-allocation-profiling-with-visual-studio-2012.aspx and it states you can make snapshots however I cannot find this feature in the professional version of Visual Studio.

What tools can I use to profile a .Net application in Visual Studio 2010 Professional Edition

Visual Studio 2010 Professional Edition doesn't contain the profiler. http://www.microsoft.com/visualstudio/en-us/products/2010-editions/product-comparison
What free alternatives are there?
It looks like MS has provided a stand alone tool that you can use
EQATEC Profile is the only free one that I'm aware of, but I've never used it. http://www.eqatec.com/tools/profiler/
I've personally had great success with JetBrains' dotTrace profiler in the past. http://www.jetbrains.com/profiler/
RedGate also has their ANTS Performance Profiler product. http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/
Neither of these are free, although usually the trial period is enough to diagnose a few problems to work on for awhile. :)
AQtime: http://smartbear.com/products/free-tools/aqtime-standard/
Another good alternative is the built in profiler that comes with SharpDevelop: http://www.icsharpcode.net/opensource/sd/

Visual Studio and C# and Web Developer Productivity Tools /Helps

I'm looking into Productivity tools for developing in C# / Visual Studio 2008 (pr0) and developing web apps (not using MVC).
Anything from favourite visual studio shortcuts to external tools and plug-ins.
Ctrl+. is one of my favorites. It adds a Using statement for the current class if you don't already have it.
For example if you have this:
Regex
And you hit Ctrl+.. Visual Studio will add
using System.Text.RegularExpressions;
to the top of your file.
I also like Code Rush and Refactor Pro from DevExpress.
A very interesting one that was just announced is Telerik's JustCode. It's basically a new refactoring tool (such as Resharper and CodeRush, also very good productivity improvement tools), but also handles Javascript in web projects.
Tools like these can dramatically improve the amount you can get done in a short amount of time.
ANTS Profiler from Red Gate helped our company find a lot of bottlenecks in our C# code.
Reflector from Red Gate PowerCommands visual studio add-in any form of Grep
We've just started using GhostDoc which is pretty useful for quickly generating outlines of comments especially when you're generating your documentation from your XML comments. It's definitely saved me some time.
its not a tool but a big reference chart - you can print it out and hang it on at your work area, to refer quick key bindings http://www.microsoft.com/en-us/download/details.aspx?id=7162

Best C# Profiler?

Merged with What Are Some Good .NET Profilers?.
Recently I used RedGate ANTS profiler which seems pretty good, but the application I tried to profile was crashing due to DivideByException, where as running in inside Visual Studio was fine for both debug and release.
Are there other/better C# profilers that you know of?

Categories