Using PerfTips to identify bottlenecks in code
PerfTips are definitely one of my favorite features of Visual Studio 2015. Explaining what they do doesn't do them justice. You have to see them in action.
Getting ready
Do not confuse PerfTips with CodeLens. PerfTips is a separate option from CodeLens in Visual Studio.
How to do it…
- PerfTips are enabled by default. But just in case you are not seeing any PerfTips, go to Tools | Options, and expand the Debugging node. Under General, to the bottom of the settings page, you will see an option called Show elapsed time PerfTip while debugging. Ensure that this option is checked:
- We will create a few simple methods that mimic long-running tasks. To do this, we will just sleep the thread for a couple of seconds. In the
Recipes.cs
file, add the following code:public static void RunFastTask() { RunLongerTask(); } private static void RunLongerTask() { Thread.Sleep(3000); BottleNeck(); } private static void BottleNeck() { Thread...