performance - dotTrace - 我应该为我的桌面应用程序使用哪些分析设置?

标签 performance profiling dottrace

使用 dotTrace 时,我必须选择分析模式和时间测量方法。 Profiling modes是:

  • 追踪
  • 逐行
  • 采样

  • time measurement methods是:
  • 挂时(性能计数器)
  • 线程时间
  • 挂墙时间(CPU 指令)

  • 跟踪和逐行不能使用线程时间测量。但这仍然让我有七种不同的组合可以尝试。我现在已经阅读了十多次关于这些的 dotTrace 帮助页面,但我仍然没有比我开始选择哪个更了解。

    我正在开发一个 WPF 应用程序,该应用程序读取 Word 文档,提取所有段落和样式,然后遍历提取的内容以挑选文档部分。我正在尝试优化这个过程。 (目前它需要一个多小时才能完成,所以我试图在给定的时间长度内对其进行分析,而不是直到它完成。)

    哪种分析和时间测量类型会给我最好的结果?或者如果答案是“取决于”,那么它取决于什么?给定的分析模式或时间测量方法的优缺点是什么?

    最佳答案

    分析类型:

  • 采样 :最快但最不准确的分析类型,最小的分析器开销。本质上相当于每秒多次暂停程序并查看堆栈跟踪;因此每个方法的调用次数是近似的。对于在方法级别识别性能瓶颈仍然有用。

    以采样模式捕获的快照占用的磁盘空间要少得多(我会说少 5-6 个空间。)
    用于初始评估或分析长期运行的应用程序(听起来像您的情况。)
  • 追踪 :记录每种方法所用的持续时间。分析下的应用程序运行速度较慢,但​​作为返回,dotTrace 显示每个函数的准确调用次数,并且函数计时信息更准确。这有利于深入研究方法级别的问题细节。
  • 逐行 :逐行分析程序。最大的资源消耗,但最细粒度的分析结果。减慢程序速度。这里首选的策略是最初使用另一种类型进行分析,然后手动选择函数进行逐行分析。


  • 至于仪表种类,我认为它们在Getting started with dotTrace Performance 中描述得很好。由伟大的哈迪哈里里。

    Wall time (CPU Instruction): This is the simplest and fastest way to measure wall time (that is, the time we observe on a wall clock). However, on some older multi-core processors this may produce incorrect results due to the cores timers being desynchronized. If this is the case, it is recommended to use Performance Counter.

    Wall time (Performance Counter): Performance counters is part of the Windows API and it allows taking time samples in a hardware-independent way. However, being an API call, every measure takes substantial time and therefore has an impact on the profiled application.

    Thread time: In a multi-threaded application concurrent threads contribute to each other's wall time. To avoid such interference we can use thread time meter which makes system API calls to get the amount of time given by the OS scheduler to the thread. The downsides are that taking thread time samples is much slower than using CPU counter and the precision is also limited by the size of quantum used by thread scheduler (normally 10ms). This mode is only supported when the Profiling Type is set to Sampling



    然而它们并没有太大的不同。

    我不是分析自己的向导,但在你的情况下,我会从采样开始以获得执行时间非常长的函数列表,然后我会将它们标记为逐行分析。

    关于performance - dotTrace - 我应该为我的桌面应用程序使用哪些分析设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9572710/

    相关文章:

    r - 如何改进 R 中 for 循环中的简单减法?

    jetbrains-ide - 连接到 RemoteAgent 时出现无法识别的故障异常

    c++ - std::lock_guard 和 #pragma omp critical 之间的区别

    c++ - 为什么我的程序不能在GDB在线编译器/调试器或Visual Studio C++ 2019中运行?

    php - PHP 的 'profiler with visualization' 和 `full backtrace visualization` ?

    java - 开发javaagents时如何运行测试?

    c# - 有没有办法使用 DotTrace 获取单个方法调用的执行时间?

    c# - 当我对一个程序进行采样分析时,它实际上运行得比不进行分析更快,这是怎么回事?

    从 csv LOAD DATA LOCAL INFILE 后 MySQL 变慢

    python - 找到代码中最耗时部分的可靠方法是什么?