Top Banner
www.xedotnet.org Debugging Performance Issues Using Visual Studio Mirco Vanini Microsoft® MVP Windows Development AllSeen Alliance - AllJoyn® Ambassador Open Connectivity Foundation - OCF® Ambassador
18

Debugging Performance Issues Using Visual Studio

Jan 22, 2018

Download

Technology

Mirco Vanini
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Debugging Performance Issues Using Visual Studio

www.xedotnet.org

DebuggingPerformanceIssues UsingVisualStudio

MircoVaniniMicrosoft®MVPWindowsDevelopmentAllSeenAlliance- AllJoyn®AmbassadorOpenConnectivityFoundation- OCF®Ambassador

Page 2: Debugging Performance Issues Using Visual Studio

Why is performanceimportant?Continuously evaluate performanceduring normaldebugging

PerfTipsMemorytoolCPUgraph

Drill into thedetails ofaperformanceissueTimeline toolCPUtoolStandalone Profiler

18/11/17 2

Agenda

Page 3: Debugging Performance Issues Using Visual Studio

18/11/17 3

Why is performanceimportant?

0%

10%

20%

30%

40%

50%

60%

70%

80%

AppFreezes Crashes SlowResponsiveness HeavyBatteryUsage

Reasonsforbadreviews

Page 4: Debugging Performance Issues Using Visual Studio

Theability tomonitorperformancewhile debugging,andcorrelateperformancedatawithdebugging activity

Amuch richer andmoreuseful experience forIntelliTrace andtheOutputwindow,dramaticallyshortening thetimeit takesyou todiagnose anissue orverify afix.

18/11/17 4

WhatareDiagnosticTools?

Page 5: Debugging Performance Issues Using Visual Studio

Demo

18/11/17 5

PerfTips(tooltips with performanceinformation)

Page 6: Debugging Performance Issues Using Visual Studio

IndicatinghowlongtheprogramwasrunningduringtheprevioussteporsincethelastbreakpointQuickly measure timebetween breaksExcludes majordebugger related overhead• Timestopped underthedebugger (e.g.stopped at abreakpoint)• Symbol loadingBestsuited fororder ofmagnitude measurements• Greatest accuracy onCLR4.6andWindows10

18/11/17 6

PerfTips

Page 7: Debugging Performance Issues Using Visual Studio

ShowsCPUutilization across all available coresSpikes canbeinteresting,even if less than 100%Available after debugging sessionhas stopped

18/11/17 7

CPUgraph

Page 8: Debugging Performance Issues Using Visual Studio

Thegarbagecollectorservesasanautomaticmemorymanager• Enables you todevelop your application without having tofreememory• Allocates objects onthemanaged heap efficiently• Reclaims objects that arenolonger being used,clears theirmemory,andkeeps thememory available forfutureallocations.Managed objects automatically get cleancontent tostartwith,sotheir constructors donot have toinitialize every datafield• Provides memory safety bymaking sure that anobjectcannot usethecontent ofanother object

18/11/17 8

FundamentalsofGarbageCollection

Page 9: Debugging Performance Issues Using Visual Studio

Threecommoncausesofmemoryleaksinmanagedapplications• Holdingreferencestomanagedobjects• Failingtoreleaseunmanagedresources• FailingtodisposeDrawingobjects

18/11/17 9

CommonCauses ofMemoryLeaks in.NET

Page 10: Debugging Performance Issues Using Visual Studio

Demo

18/11/17 10

MemoryTool

Page 11: Debugging Performance Issues Using Visual Studio

Comparememory consumption overtime• Provides sizes andcount foreach type• Filters outobjects marked forgarbage collection (.NET)Worksforboth C++and.NETapps

18/11/17 11

Memorytool

Page 12: Debugging Performance Issues Using Visual Studio

18/11/17 12

Performanceprofile

Page 13: Debugging Performance Issues Using Visual Studio

18/11/17 13

Performancewizard

Page 14: Debugging Performance Issues Using Visual Studio

Demo

18/11/17 14

Timeline Tool

Page 15: Debugging Performance Issues Using Visual Studio

Identify app performanceissues dueto• Parsing &Layout• Applicationcodeorother runtime CPUconsumptionMonitorFPSthroughput

18/11/17 15

Timeline tool

Page 16: Debugging Performance Issues Using Visual Studio

Records which functions areusing theCPUthemost• Takes acallstack fromtheCPUevery millisecond• ShowsaggregatereportCollects mixed modestacks (.NET&C++)

18/11/17 16

CPUtool

Page 17: Debugging Performance Issues Using Visual Studio

PartofVisualStudioRemotetoolsCPUsampling onWindows8+works withx-copyhttps://www.visualstudio.com/downloads/

18/11/17 17

Standalone Profiler

Page 18: Debugging Performance Issues Using Visual Studio

18/11/17 18

Who Iam

[email protected]@MircoVanini

MircoVaniniMicrosoft®MVPWindowsDevelopmentAllSeen Alliance- AllJoyn®AmbassadorOpenConnectivityFoundation- OCF®Ambassador

TinyCLR.it