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.
- Day #1: Code Assistance in Visual Studio 2015
- Day #2: Code Analyzers in Visual Studio 2015
- Day #3: Renaming Assistance in Visual Studio 2015
- Day #4: Code Refactoring in Visual Studio 2015
- Day #5: Debugging Improvements in Visual Studio 2015 (Breakpoint Configuration and New Error List)
- Day #6: Debugging Improvements in Visual Studio 2015 (Tool Window Support for LINQ and Lambda)
- Day #7: PerfTip in Visual Studio 2015
- Day #8: New Diagnostic Tool Window in Visual Studio 2015
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.
The diagnostic tool window can be launched via Debug-> Show Diagnostic Tools option as shown in the below image.
Under the timeline are three important views.
- The Debugger Events view displays breakpoint, output, and IntelliTrace events.
- The Memory view displays the processor or memory usage in bytes.
- The CPU utilization view displays the percent of processor CPU usage.
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.
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.
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.
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.
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.
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.
The blue bar indicates the time from the last breakpoint until the time that the debugging session was paused, using the Break All feature.
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.
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.
In this sample debugging session you can see there is one snapshot.
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.
The CPU utilization section of the Diagnostic Tools window helps you monitor the CPU usage of your application by viewing a live CPU graph.
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.
You can use the Diagnostic Tools window to aid in your debugging process and improve productivity and performance.
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.