Tuesday, September 4, 2018

How do I get inclusive sample that aggregates children?

Leave a Comment

In VS 2015, I have run CPU Usage Profile and I see a function (FunctionA) that has Inclusive Samples of 10%. This function is called from several other functions (ParentFunctions 1,2&3).

When I look at Inclusive Samples of the 3 parent functions, their combined inclusive sample is way less than the IS of the child FunctionB!

How can I tell which Parent is causing the most usage? I am used to using a previous profiler where the Parent "CPU Time" was an aggregate of its children. Why do Inclusive Samples NOT work like this? How can I switch to something that gives me actual time? Or, is there some other I am able to tell which is the naughty parent?

1 Answers

Answers 1

You have the usage profile but what people do not know is that Visual Studio 2015 has a sampling profiling method:

The sampling profiling method of the Visual Studio Profiling Tools interrupts the computer processor at set intervals and collects the function call stack. A call stack is a dynamic structure that stores information about the functions that are executing on the processor.

But do note the requirements:

Visual Studio Ultimate, Visual Studio Premium, Visual Studio Professional

It will give you also the inclusive samples:

The total number of samples that are collected during the execution of the target function.

This includes samples that are collected during the direct execution of the function code and samples that are collected during the execution of child functions that are called by the target function.

The steps to produce it:

  • Open the solution in Visual Studio. Set the configuration to Release. (Find the Solution Configurations box on the toolbar, which is set to Debug by default. Change it to Release.)
  • On the Debug menu, select Profiler, and then select Performance Profiler.
  • Check the Performance Wizard option, and click Start.
  • Check the CPU Sampling (recommended) option and click Finish.

Please do note:

  • After you finish running the application, the Summary view of the profiling data appears in the main Visual Studio window and an icon for the new session appears in the Performance Explorer window.

  • If you are not an administrator on the computer that you are using, you should run Visual Studio as an administrator while you are using the profiler. (Right-click the Visual Studio application icon, and then click Run as administrator.

use this guide for reference.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment