Working with Visual Studio’s Profiler

The in-built Visual Studio’s Profiler can quickly detect performance bottlenecks. To get started with Profiler, you would need Visual Studio Ultimate or Premium version. It’s located under VS top menu -> Analyze->Launch Performance Wizard. In step1, choose “Instrumentation” then follow subsequent steps till finish.

2

Few basic definitions, better be familiar with.

Elapsed Inclusive Time = Time spent on this current function and children (ms)
Elapsed Exclusive time = Time spent on this current function (ms)
App Inclusive time = Processing time on this current function and children without wait time for IO or other threads.

Here’s the basic summary view after code profiling is completed on my simplified example page.

5

Notice the section “Functions with most individual work”. At the top is the most expensive function. Click on that and it will lead you to this view.

  6

Most of the time, “Elapsed Exclusive time” along with Caller/Callee view can detect the biggest hurdle in minutes.
Elapsed Exclusive time is basically the time took to execute only those lines of code in that function without any external I/O or wait.
So if I go to the most nested function in any costly execution chain, costly in terms of time/resources, I already know the major hurdle.
This view basically tells all —
1) How much time was spent on that particular function
2) Which all functions called that function and how many times each?
3) This function called which all functions and their respective time.

7

Another view which I found very helpfull is functions.
This view lists all functions with the various amount of time each one took.

9

This tool just helps in detecting the most performance-expensive piece of code. We need to go back and fix the code and again run profiler to see the relative performance-gain.
The profiling results can be compared, filtered, exported to a csv/excel file. The profiler can be paused/resume to profile only the affected chain of logic.

Enjoy profiling. Thanks for reading.

Advertisements
This entry was posted in General ASP.Net C#. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s