c# - 我如何获得包含 child 的包容性样本?

标签 c# profiling

在 VS 2015 中,我运行了 CPU 使用情况分析,我看到一个函数 (FunctionA) 包含 10% 的样本。这个函数被其他几个函数调用(ParentFunctions 1,2&3)。

当我查看 3 个父函数的包含样本时,它们的组合包含样本远小于子函数 B 的 IS!

我如何判断哪个父级使用最多?我习惯于使用以前的分析器,其中父级“CPU 时间”是其子级的集合。为什么包容性样本不能像这样工作?我怎样才能切换到给我实际时间的东西?或者,有没有其他我能分辨出哪个是顽皮的 parent ?

最佳答案

您有使用概况,但人们不知道的是 Visual Studio 2015 有一个 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.

但请注意要求:

Visual Studio Ultimate, Visual Studio Premium, Visual Studio Professional

它还会给你包含的样本:

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.

制作步骤:

  • 在 Visual Studio 中打开解决方案。将配置设置为发布。 (找到工具栏上的Solution Configurations框,默认设置为Debug。将其更改为Release。)
  • Debug 菜单上,选择 Profiler,然后选择 Performance Profiler
  • 选中性能向导选项,然后单击开始
  • 选中CPU 采样(推荐) 选项并单击完成

请注意:

  • 应用程序运行完毕后,分析数据的摘要 View 会出现在 Visual Studio 主窗口中,新 session 的图标会出现在性能资源管理器窗口中。

  • 如果您不是所用计算机的管理员,则在使用探查器时应以管理员身份运行 Visual Studio。 (右键单击 Visual Studio 应用程序图标,然后单击以管理员身份运行。

使用这个guide for reference .

关于c# - 我如何获得包含 child 的包容性样本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51361823/

相关文章:

c# - 如何在 MS SQL Server 2014 中创建新的数据类型?

c# - 如何建立一种防火墙

debugging - 使用堆栈进行分析

java - RandomAccessBuffer 的性能改进

c# - 如何为远程 Service Fabric 集群创建 actor 代理

c# - 在使用 EF Core 时使用 [ForeignKey] 访问相关表而实际上在数据库中没有外键

c# - 请对 C# IDisposable 做一些说明

c++ - 为什么 clock() 在集群机器上不起作用

delphi - 寻找内存泡沫

windows性能记录器记录具体过程