适用于 Windows 的体面分析器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/170036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:23:37  来源:igfitidea点击:

Decent profiler for Windows?

c++windowsperformanceprofiling

提问by olliej

Does windows have any decent sampling (eg. non-instrumenting) profilers available? Preferably something akin to Shark on MacOS, although i am willing to accept that i am going to have to pay for such a profiler on windows.

Windows 是否有任何不错的采样(例如非检测)分析器可用?最好是类似于 MacOS 上的 Shark,尽管我愿意接受我将不得不为 Windows 上的这种分析器付费。

I've tried the profiler in VS Team Suite and was not overly impressed, and was wondering if there were any other good ones.

我已经尝试过 VS Team Suite 中的分析器,并没有给我留下太深的印象,并且想知道是否还有其他好的分析器。

[Edit: Erk, i forgot to say this is for C/C++, rather than .NET -- sorry for any confusion]

[编辑:呃,我忘了说这是针对 C/C++,而不是 .NET——抱歉有任何混淆]

采纳答案by Dickon Reed

Intel VTuneis good and is non-instrumenting. We evaluated a whole bunch of profilers for Windows, and this was the best for working with driver code (though it does unmanaged user level code as well). A particular strength is that it reads all the Intel processor performance counters, so you can get a good understanding of why your code is running slowly, and it was useful for putting prefetch instructions into our code and sorting out data layout to work well with the cache lines, and the way cache lines get invalidated in multi core systems.

英特尔 VTune很好,而且是非检测的。我们为 Windows 评估了一大堆分析器,这是处理驱动程序代码的最佳选择(尽管它也可以处理非托管用户级代码)。一个特别的优势是它读取所有英特尔处理器性能计数器,因此您可以很好地了解代码运行缓慢的原因,并且它对于将预取指令放入我们的代码并整理数据布局以与缓存行,以及缓存行在多核系统中失效的方式。

It is commercial, and I have to say it isn't the easiest UI in the world.

它是商业性的,我不得不说它不是世界上最简单的 UI。

回答by user15071

For Windows, check out the free Xperfthat ships with the Windows SDK. It uses sampled profile, has some useful UI, & does not require instrumentation. Quite useful for tracking down performance problems. You can answer questions like:

对于 Windows,请查看Windows SDK 附带的免费Xperf。它使用采样配置文件,具有一些有用的用户界面,并且不需要检测。对于跟踪性能问题非常有用。您可以回答以下问题:

Who is using the most CPU? Drill down to function name using call stacks.

谁使用的 CPU 最多?使用调用堆栈深入到函数名称。

Who is allocating the most memory?

谁分配的内存最多?

Outstanding memory allocations (leaks)

未完成的内存分配(泄漏)

Who is doing the most registry queries?

谁在进行最多的注册表查询?

Disk writes? etc.

磁盘写入?等等。

回答by Naaff

I know I'm adding my answer months after this question was asked, but I thought I'd point out a decent, open-source profiler: Very Sleepy.

我知道我会在提出这个问题几个月后添加我的答案,但我想我会指出一个不错的开源分析器:非常困

It doesn't have the feature count that some of the other profilers mentioned before do, but it's a pretty respectable sampling profiler that will work very well in most situations.

它没有之前提到的其他一些分析器的功能计数,但它是一个非常受人尊敬的采样分析器,在大多数情况下都能很好地工作。

回答by Die in Sente

AMD's CodeAnalyst is FREEhere

AMD 的 CodeAnalyst在这里免费

回答by Greg Whitfield

We use both VTune and AQTime, and I can vouch for both. Which works best for you depends on your needs. Both have free trial versions - I suggest you give them a go.

我们同时使用 VTune 和 AQTime,我可以保证两者。哪种最适合您取决于您​​的需求。两者都有免费试用版 - 我建议你试一试。

回答by bk1e

The Windows Driver Kitincludes a non-instrumenting user/kernel sampling profiler called "kernrate". It seems useful for profiling multi-process applications, applications that spend most of their time in the kernel, and device drivers (of course). It's also available in the KrView (Kernrate Viewer)and Windows Server 2003 Resource Kit Toolspackages.

驱动程序开发工具包包括非插装用户/内核采样分析器称为“kernrate”。它对于分析多进程应用程序、大部分时间都在内核中的应用程序和设备驱动程序(当然)很有用。它也可以在KrView (Kernrate Viewer)Windows Server 2003 Resource Kit Tools包中使用。

Kernrate works on Windows 2000 and later (unlike Xperf, which requires Vista / Server 2008). It's command-line based and the documentation has a somewhat intimidating list of options. I'm not sure if it can record call stacks or just the program counter. If you use a symbol server, make sure to put an up-to-date dbghelp.dlland symsrv.dllin the same directory as kernrate.exeto prevent it from using the ancient version of dbghelp.dllthat is installed in %SystemRoot%\system32.

Kernrate 适用于 Windows 2000 及更高版本(与 Xperf 不同,它需要 Vista / Server 2008)。它是基于命令行的,文档中有一些令人生畏的选项列表。我不确定它是否可以记录调用堆栈或仅记录程序计数器。如果你使用一个符号服务器,请务必把一个上最新dbghelp.dllsymsrv.dll在同一个目录中kernrate.exe,以防止它使用的古代版dbghelp.dll是安装在%SystemRoot%\system32

回答by Jon Trauntvein

I have tried Intel's vtune with a rather large project about two years ago. It was an instrumenting profiler then and it took so long to instrument the DLL that I was attempting to profile that I eventually lost patience after an hour.

大约两年前,我在一个相当大的项目中尝试了英特尔的 vtune。当时它是一个检测分析器,检测 DLL 需要很长时间,以至于我试图分析一个小时后我最终失去了耐心。

The one tool that I have had quite good success and which i would highly recommend is that of AQTime. It not only provides excellent performance profiling resources but it also doe really good memory profiling which has been of significant help to me in tracking down memory leaks.

我已经取得了相当大的成功并且我强烈推荐的一种工具是AQTime。它不仅提供了出色的性能分析资源,而且还进行了非常好的内存分析,这对我跟踪内存泄漏有很大帮助。

回答by SamB

Luke Stackwalkerseems promising -- it's not as polished as I'd like, but it is open source and it does do something that seems very close to what @Mike Dunlavey keeps saying we ought to do. (Of course, it then tries to smoosh it all down into the typically-unhelpful call graphs that Mike is so weary of, but it shouldn't be too hard to fix that with the source as our ally.)

Luke Stackwalker看起来很有前途——它没有我想要的那么精致,但它是开源的,它确实做了一些与@Mike Dunlavey 一直说我们应该做的事情非常接近的事情。(当然,它随后会尝试将其全部归结为 Mike 非常厌烦的通常无用的调用图,但以源作为我们的盟友来解决这个问题应该不会太难。)

It even seems to count time spent waiting in the kernel, as far as I can tell...

据我所知,它甚至似乎计算了在内核中等待的时间......

回答by Jonathan Allen

I'm not sure what a non-instrumenting profiler is, but I can say for .NET I love RedGate's ANTS Profiler. Version 3 beats the MS version for ease of use and Version 4, which allows arbitrary time slices, makes MS look like a joke.

我不确定什么是非检测分析器,但我可以说对于 .NET,我喜欢 RedGate 的 ANTS Profiler。版本 3 在易用性方面优于 MS 版本,版本 4 允许任意时间片,让 MS 看起来像个笑话。