Diving into Visual Studio 2015 (Day #8): Diagnostic Tool Window in Visual Studio 2015

Diagnostic tool window in Visual Studio 2015

Introduction

The earlier parts of this series talked about Visual Studio 2015 improvements and enhancements. This article on Visual Studio 2015 will cover another interesting feature of Visual Studio 2015 i.e. Diagnostic Tool Window.We’ll have a glance over the new diagnostic window and try to cover the topic with practical examples, thus exploring this diagnostic tool window helps in debugging and monitoring.

Series

Diagnostic Tool Window

The new Diagnostic Tools window in Visual Studio appears whenever you run the application with debugging.

This window provides a an ample amount of information that is very helpful when debugging the application. It contains a timeline across the top that provides a temporal display of application’s debugging session.

image

The diagnostic tool window can be launched via Debug-> Show Diagnostic Tools option as shown in the below image.

image

Under the timeline are three important views.

  • The Debugger Events view displays breakpoint, output, and IntelliTrace events.

image

  • The Memory view displays the processor or memory usage in bytes.

image

  • The CPU utilization view displays the percent of processor CPU usage.

image

At the bottom of the Diagnostic Tools window are tabs with additional detail and options. The yellow arrow at the bottom shows that code being debugged is currently at a breakpoint.

image

This article will cover the different views of Diagnostic Tool Window, one by one. We’ll use the existing code base as a sample to explore the features. Place the breakpoints at two locations as shown below in the existing Program.cs file we have been using throughout the prior articles.

image

Now run the application and wait for execution to pause at break point. Now open the Diagnostic tools or press Ctrl+Alt+F2. You get following view of Diagnostic tool window.

image

TimeLine

This example debugging session was 0.19 seconds in length from the time of application start until the current breakpoint, and we are looking at about 5.5 seconds of that time here in the timeline. The black bars here and here allow you to select a portion of the timeline.

image

The selected time interval, shown in white, is the area of the timeline that you want to focus on. Drag either black bar to adjust the selection area. The other sections of this window adjust based on the location of the black bars.  Note that since our selected area includes part of a red line in the breakpoint track, the list also displays the end of that breakpoint line.

image

Debugger Events

The Debugger Events view in the Diagnostic Tools window displays events that occurred during the debugging session. This view is broken into tracks. The Break Events track shows events which stopped execution of the application, such as breakpoints that were hit, stepping through the code or breaking exceptions. The bars indicate the amount of time the application was running in between break events. The bars in this track are color coded, red indicates a breakpoint or breaking exception, yellow indicates a step through the code, and blue indicates a break all operation.

image

 

 

The blue bar indicates the time from the last breakpoint until the time that the debugging session was paused, using the Break All feature.

image

 

 

Hover over a bar to view the elapsed time.

The IntelliTrace track shows all of the other events collected by IntelliTrace, such as ADO.NET calls, file access, and so on. It is also color coded, black for important events, gray for less important events, and purple for custom events.

Process Memory

The Process Memory section of the Diagnostic Tools window helps you monitor the memory usage of the app while you are debugging. A memory usage tool was introduced in Visual Studio 2013 as part of the Performance and Diagnostics hub. In Visual Studio 2015, this tool was merged into the Diagnostic Tools window and enhanced. As with the current memory usage tool, you can take a memory snapshot at any point in time and compare it against another snapshot.

image

In this sample debugging session you can see there is one snapshot.

image

Using the memory usage tool helps you analyze the cause of memory spikes or leaks.  You can also View the Heap information through Memory Usage window.

image

CPU

The CPU utilization section of the Diagnostic Tools window helps you monitor the CPU usage of your application by viewing a live CPU graph.

image

This graph shows you how much CPU resources are used by the code. Looking at the CPU usage with the debugger events helps you correlate spikes in CPU with the execution of the code, making it easier to debug CPU-related issues.

You can switch on CPU profiling for more detailed CPU usage statistics.

image

You can use the Diagnostic Tools window to aid in your debugging process and improve productivity and performance.

Conclusion

In this article we covered a very useful and critical feature of Visual Studio 2015, named Diagnostic Tools Window.We saw how Diagnostic tool window can help you debug your code and monitor CPU and memory usage too.

Advertisements

Author: Akhil Mittal

Akhil Mittal is a Microsoft MVP,C# Corner MVP, Code project MVP, blogger, programmer by heart and currently working as a Sr. Analyst in Magic Software and have an experience of more than 9 years in C#.Net. He holds a B.Tech in Computer Science and hold a diploma in Information Security and Application Development. His work experience includes Development of Enterprise Applications using C#,.Net and Sql Server,Analysis, Product Management as well as Research and Development. He is a MCP in Web Applications(MCTS-70-528,MCTS-70-515) and .Net Framework 2.0 (MCTS-70-536).