analyze your code with visual studio 2015 diagnostic tools
TRANSCRIPT
![Page 1: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/1.jpg)
Analyze Your Code With Visual Studio 2015 Diagnostic Tools
Ken Cenerelli@KenCenerelli
![Page 2: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/2.jpg)
About Me
Twitter: @KenCenerelliEmail: [email protected]: kencenerelli.wordpress.comLinkedIn: linkedin.com/in/kencenerelli
Bio: Programmer Writer Microsoft MVP - Visual Studio and
Development Technologies Microsoft TechNet Wiki Guru Co-Organizer of CTTDNUG Technical reviewer of multiple books
CTTDNUG
Ken Cenerelli
![Page 3: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/3.jpg)
![Page 4: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/4.jpg)
Source: http://dilbert.com/strip/1995-11-13
![Page 5: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/5.jpg)
Typical Debugging Session1. Realize there is a bug
2. Use best-guess scenario to place a breakpoint
3. Reproduce steps and hope your breakpoint is hit before bug appears
4. Breakpoint is hit, examine the code by stepping through
5. Root cause not identified
6. Repeat steps 2 thru 5 until bug is discovered
![Page 6: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/6.jpg)
Old Diagnostic Tools• In Visual Studio 2013, the tools were not well advertised
• Instruments like Memory Usage and CPU Usage were made available in the Performance and Diagnostics hub in VS 2013 Update 2
• They are found by clicking on Performance and Diagnostics in the Debug or Analyze menu
![Page 7: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/7.jpg)
New Diagnostic Tools Window (aka Why Should I Care?)• Visual Studio 2015 brings Diagnostic Tools into the debugging experience when you hit F5
• The new window is active during the debugging session
• It is designed to change your debugging workflow
• You no longer have to create breakpoints, hit F5, wait for the breakpoint to be hit, and then check the Locals window
• You should now think, “What did IntelliTrace find?”
![Page 8: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/8.jpg)
Diagnostic Tools Window Components• IntelliTrace UI is revamped and now is in Diagnostic Tools Window
• Memory and CPU usage graphs added
• Take memory snapshots and time sections of code with PerfTips
![Page 9: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/9.jpg)
Supported SKUs• Diagnostic Tools can be found in the following Visual Studio editions:
Visual Studio Code
Visual Studio Community
Visual Studio Professional
Visual Studio Enterprise
IntelliTrace+ more event categories
▪
Memory Usage ▪ ▪ ▪
CPU Usage ▪ ▪ ▪
PerfTips ▪ ▪ ▪
![Page 10: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/10.jpg)
Supported Project TypesDiagnostic Tools are available in all the following project types:• Managed WPF, WinForms, and Console projects• Native Win32, Console, and MFC projects• ASP.NET projects running on local IIS and IIS Express (including MVC & Web API)• Managed or Native Windows Store projects• Debugging sessions started using Debug > Attach to Process• Debugging apps running on remote desktop devices
![Page 11: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/11.jpg)
Non-supported Project TypesNo support currently for the following projects:• Windows Store projects that are using JavaScript• Windows Store projects that are running on a Windows Phone• Debugging when Managed or Native Compatibility Mode is checked in Tools > Options >
Debugging• Native Phone projects (Cordova, Xamarin)
![Page 12: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/12.jpg)
IntelliTrace• IntelliTrace is a recorder for your debugging sessions
• It captures the call stack along with local variable info for that moment of time
• You can go back in time with Historical Debugging
• Captured events are represented on a timeline
• The Events timeline is split into three tracks: Break Events, Output Events, and IntelliTrace Events
• It provides the same events you would get from implementing extensive logging frameworks (log4net, NLog) but without the work
![Page 13: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/13.jpg)
PerfTips• Provides timing of previously executed code blocks
• No more Stopwatch.Start / Stopwatch.Elapsed
• Runs in all types of projects
• Works with remote debugging in Azure
• PerfTips discounts network latency issues when debugging on a remote machine
• TIP: Take multiple measurements to discover the range and median values of the code being measured
![Page 14: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/14.jpg)
Demo• Diagnostic Tools Window
• IntelliTrace Events
• PerfTips
![Page 15: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/15.jpg)
Visual Studio 2015 Update 1• Improvements to the Events tab of the Diagnostic Tools Window:• Improved the filtering menu• Added the ability to search• Added category prefixes to all events
![Page 16: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/16.jpg)
Memory Usage• Monitor memory usage of your app and take snapshots of your memory so that you can inspect the contents of the heap to find memory leaks
• Includes memory allocated on both the managed and native heaps
• Tied to the debugger your project is using (Managed Only, Native Only, or Mixed Mode)
• Records only the time your application is running and filters out the time spent in break states
• Can snapshot sections of your code before and after it is run to get the delta
• Heap analysis view for deeper investigation of the process memory by type
![Page 17: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/17.jpg)
CPU Usage• In many cases the CPU is the bottleneck when performance problems arise
• It can be difficult to know where to start when you want to make your code run faster
• Measures the CPU’s resources in terms of how much time each core in the CPU spends executing your code
• Lets you see which of your functions are using the most CPU
![Page 18: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/18.jpg)
Demo• Memory Usage
![Page 19: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/19.jpg)
Visual Studio 2015 Update 1• Improvements to CPU profiling in the Diagnostic Tools Window:• Do full CPU profiling without stopping your debug session• Control both the execution of the application as well as the collection of CPU profiling data• Drill into a section of code by hitting a breakpoint, turning profiling on, and then running to the next
breakpoint
![Page 20: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/20.jpg)
Start Diagnostic Tools Without Debugging• Provides a true representation of your CPU and Memory
• Removes the overhead added by the debugger when using the Diagnostic Tools window
• Full analysis only occurs after your profiling session is complete
• Contains additional features like Application Timeline and Network Usage
• Tools can be combined by checking more than one box before you click Start so that you can cross-correlate data and diagnose performance issues more effectively
• TIP: Try running in Release build mode to make sure the debugger is not the cause of your slow downs
![Page 21: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/21.jpg)
Demo• Start Diagnostic Tools Without Debugging
![Page 22: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/22.jpg)
Additional Diagnostic Tools• IntelliTrace Standalone Collector• Referred to as Non-Live Debugging, it is when your application executes without Visual Studio attached• Application data is recorded to an .itrace file which can then be imported into VS for debugging
• Application Insights• Allows you to monitor your deployed live applications through telemetry data stored in Azure• Understand how users use your apps• Detect issues quicker and solve the right problems faster
• PerfView• PerfView is a performance-analysis tool that helps isolate CPU and memory-related performance issues• A standalone tool that goes deeper than Diagnostic Tools
![Page 23: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/23.jpg)
Resources• Visual Studio ALM Blog: • http://bit.ly/1Msso3F
• Channel 9 Videos:• http://bit.ly/1Le96gs• http://bit.ly/1MNNJUk• http://bit.ly/1MGWMuB
• MSDN Magazine Articles:• http://bit.ly/1IZOds9• http://bit.ly/1OJ3NgK
![Page 24: Analyze Your Code With Visual Studio 2015 Diagnostic Tools](https://reader035.vdocuments.us/reader035/viewer/2022062823/587820c61a28aba12d8b6773/html5/thumbnails/24.jpg)
Summary• Slides:• Through CTTDNUG• Blog (kencenerelli.wordpress.com)• SlideShare (slideshare.net/KenCenerelli)
• Contact Details:• @KenCenerelli• [email protected]