这是最可靠、最快的 Windows C++你用过的探查器吗?

发布于 2024-08-22 13:26:28 字数 240 浏览 8 评论 0原文

我需要在 Windows 上分析实时 C++ 应用程序。大多数可用的分析器要么非常昂贵,要么完全杀伤力太大,或者两者兼而有之。我不需要任何 .NET 的东西。由于它是一个实时应用程序,我需要分析器尽可能快。如果它以某种方式与 Visual Studio 2005/2008 集成,那就太好了,但这不是必需的。如果这个描述让您想起您使用过的分析器,我真的很想了解它。我希望根据人们在 Windows 上使用 C++ 分析器的情况来确定一个可以完成这项工作的工具。谢谢。

I need to profile a real time C++ app on Windows. Most of the available profilers are either terribly expensive, total overkill, or both. I don't need any .NET stuff. Since it is a real time app, I need the profiler to be as fast as possible. It would be excellent if it integrated in some way with Visual Studio 2005/2008, but that's not necessary. If this description reminds you of a profiler that you have used, I would really like to know about it. I am hoping to draw from people's use of C++ profilers on Windows to pinpoint one that will do the job. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

蓝颜夕 2024-08-29 13:26:28

当我必须分析实时代码时,我认为唯一的解决方案是手动操作。您不希望覆盖太多,否则最终会减慢代码速度,但对于较小的数据集,您需要非常专注,本质上是手动选择每个点。

因此,我几年前编写了一个头文件,它定义了一些宏和捕获数据的机制,无论是作为函数计时还是作为时间线(在函数 X 中的时间 T 处)。该代码使用 QueryPerformanceCounter 进行计时和写入通过 CreateFileMapping 将数据放入命名共享内存中我可以实时查看另一个进程的计时数据。

需要重新编译才能更改我想要捕获的计时信息,但代码非常便宜,几乎对代码没有影响。

所有代码都在头文件中(带有宏保护,因此代码仅包含一次)。所以头文件本身就是我的“分析器”。我更改了标头中的一些表,然后标记目标代码,重新编译并开始分析。

When I have to profile realtime code, I think the only solution is something hand-rolled. You don't want too much coverage or you end up slowing the code down, but with a small data set, you need to be very focused, essentially picking each point by hand.

So I wrote a header file several years ago that defines some macros and a mechanism for capturing data, either as function timings or as a timeline (at time T in function X). The code uses QueryPerformanceCounter for the timings and writes the data into named shared memory via CreateFileMapping so that I can look at the timing data from another process live.

It takes a recompile to change what timing information I want to capture, but the code is so inexpensive that It has virtually no effect on the code.

All of the code is in the header file, (with macro guards so the code only gets included once). so the header file itself is my 'profiler'. I change some tables in the header, then and markup the target code, recompile and start profiling.

奢望 2024-08-29 13:26:28

考虑无分析器选项

关于性能问题,人们普遍认为测量是发现这些问题的先决条件。
并非如此。 有关该主题的更多信息。

这是调整应用程序以获得最佳性能的示例。

如果您如果您担心开销以及如何在 DSP 实时应用程序中执行此操作,我将这样做。使用真实的输入让它运行,然后使用暂停按钮将其停止。将调用堆栈捕获到记事本中。然后再次启动并重复几次。 (丢弃任何不相关的示例,例如等待用户输入或处于空闲状态的其他示例。)请注意,此过程使程序零分析开销

如果您遇到问题,您的代码运行了计时器,并且实际上只运行了总时间的一小部分,那么 a) 您可能会认为您实际上没有问题,或者 b) 您仍然可以尝试让它走得更快。如果 (b) 然后在代码中包裹一个循环,以便无论它做什么,它都会重复 10、100 或 1000 次,使其花费足够多的时间,以便样本能够落在其中。使用这些示例找出需要修复的内容以使其更快。完成后,删除外层循环,它就会像强盗一样运行。

Give consideration to the no-profiler option.

It is common wisdom regarding performance problems that measuring is a prerequisite to finding them.
Not so. More on that subject.

This is an example of tuning an app for maximum performance.

In case you're worried about overhead and how to do this in a DSP real-time app, here's how I would do it. Get it running with realistic input, and just halt it in its tracks with the pause button. Capture the call stack into Notepad. Then start it up again and repeat several times. (Throw away any sample that is irrelevant, like waiting for user input or otherwise in idle state.) Notice that this process puts zero profiling overhead on the program.

If you have the problem that your code runs off a timer and is actually running for only a small fraction of the overall time, then a) you may decide that you don't actually have a problem, or b) you can still try to make it go faster. If (b) then wrap a loop around your code so that whatever it does, it repeats 10, 100, or 1000 times, making it take a large enough fraction of time so that samples will land in it. Use those samples to find out what to fix to make it faster. When you are done, remove the outer loop, and it will run like a bandit.

鱼忆七猫命九 2024-08-29 13:26:28

我偶尔会使用一个名为 Very Sleepy 的应用程序:
http://www.codersnotes.com/sleepy

这是一个简单、不起眼的工具,我不喜欢不知道它有多适合您的需求。作为一个相当简单的采样分析器,它对我来说已经足够好了。我正在编写一个名为 SlimTune 的 .NET 分析器,它最终将获得本机支持 - 但现在还没有,而且可能需要几个月的时间才能推出。

I occasionally use an application called Very Sleepy:
http://www.codersnotes.com/sleepy

It's a simple, unassuming tool, and I don't know how well it suits your needs. It's done well enough for me, as a fairly straightforward sampling profiler. I am authoring a .NET profiler called SlimTune that will gain native support eventually -- but it's not in there now, and it could be some months before it's available.

戴着白色围巾的女孩 2024-08-29 13:26:28

性能验证器(来自我工作的公司 Software Verification)似乎匹配您正在寻找什么:

  • 采样和非采样模式。
  • C、C++、德尔福、Windows。

Performance Validator (from Software Verification, the company I work for) seems to match what you are looking for:

  • Sampling and non-sampling modes.
  • C, C++, Delphi, Windows.
你对谁都笑 2024-08-29 13:26:28

我们进行了大量的分析,并使用了 Shark(仅限 OSX)、vTune< /a>、Glowcode 以及计数器/时钟的旧宠。

其中 Shark 无疑是最好的(而且免费!),在某种程度上,我尝试将代码移植到 OSX,以便我可以使用它进行分析。不幸的是,它不能满足您的要求。

vTune 完全没有给人留下深刻的印象,它太复杂了,如果不是所有分析选项的专家,就无法获得像样的分析,前端 GUI 经常崩溃或完全损坏,而且它的采样器不会对调用堆栈进行采样,这使得它几乎对于实际了解程序中的瓶颈是如何产生的毫无用处。它也很昂贵(尽管我们最终购买了许可证)。它的优势在于它是跨平台的,你可以获得 30 天的试用期,看看你是否喜欢它。

Glowcode 很不错,仅限 IIRC Windows,并且还提供免费试用。我们已经有一段时间没有使用它了,但它可能是一个不错的起点。

我们主要将时钟用于嵌入式代码,该代码运行单个进程,系统开销很少或没有 - 这意味着我们可以准确计算操作所需的时钟周期数。就我个人而言,我不建议“滚动您自己的”分析代码(除了极其粗略的规模),原因有两个:

  • 很难解释您的进程如何安排以及正在运行哪些其他操作。
  • 分析器经常会突出显示如果没有他们的干预您永远不会认为是热点的热点。

We do a fair amount of profiling, and have used Shark (OSX only), vTune, Glowcode and the old favourite of counters/clocks.

Of those Shark is by far and away the best (and free!), to the extent that I try to keep code portable to OSX so I can use it to profile. Unfortunately, it doesn't meet your requirements.

vTune was wholly unimpressive, it was too complicated to get a decent profile out of without being an expert in what all the profiling options, the front end GUI frequently crashed or just plain broke and its sampler doesn't sample the call stack making it almost useless for actually seeing how bottlenecks in your program are arising. It was also expensive (although we ended up buying a licence). In its favour it is cross platform, and you can get a 30-day trial to see if you like it.

Glowcode was decent, IIRC windows only and also offers a free trial. It's been a while since we used it but it might not be a bad place to start.

We mostly use clocks for our embedded code, which runs single process with little or no system overhead - meaning we can count exactly the number of clock cycles operations take. Personally I wouldn't recommend "rolling your own" profiling code (except at an extremely coarse scale) for two reasons:

  • It's difficult to account for how your process gets scheduled and what other operations are running.
  • Profilers often highlight hotspots you would never have considered to be hotspots without their intervention.
随梦而飞# 2024-08-29 13:26:28

由于它是实时应用程序,因此我需要分析器尽可能快。

我不知道你所说的实时(硬实时、半硬实时、软实时)是什么意思。

我曾经不得不提高传真服务器的性能。传真协议是这样的,如果任一端延迟太长(几十或几百毫秒,视情况而定),则传真会话将断开。因此,我无法使用任何可用的商业分析器,因为它们大大减慢了服务器的执行速度:因此我添加了各种日志消息(带有时间戳)来检测代码,从而找到瓶颈。

Since it is a real time app, I need the profiler to be as fast as possible.

I don't know what you mean by real-time (hard, semi-hard, soft).

I once had to improve the performance of a fax server. The fax protocol is such that if either end delays too long (some tens or hundreds of milliseconds, depending) then the fax session is disconnected. I was therefore unable to use any commercial profiler that was available to me, because they slowed the execution of the server too much: and so instead I added various log messages (with time stamps) to instrument the code and thus find the bottle-necks.

一江春梦 2024-08-29 13:26:28

我使用 AMD CodeAnalyst 效果很好,但自然它必须在 AMD 处理器上运行。如果你挖掘得足够深,这更像是“告诉你的比你想知道的更多”的情况。
http://developer.amd.com/cpu/codeanalyst/Pages/default。 ASPX

I've used AMD CodeAnalyst to great effect, but naturally it has to run on an AMD processor. It's more a case of "tells you more than you want to know" if you dig deep enough.
http://developer.amd.com/cpu/codeanalyst/Pages/default.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文