什么是非常简单的 C++探查器(VC++)?

发布于 2024-08-28 18:29:16 字数 202 浏览 4 评论 0原文

我过去使用过一些分析器,但从未发现它们特别容易。也许我选了不好的,也许我真的不知道我在期待什么! 但我想知道是否有任何“标准”分析器可以简单地插入并工作?我不认为我需要大量详细的报告,只是为了找出主要的黑点。在这一点上,易用性对我来说更重要。

我们使用的是VC++ 2008(我个人运行的是标准版)。我不认为 IDE 中有任何工具可以实现此目的,我从主菜单中看不到任何工具?

I've used a few profilers in the past and never found them particularly easy. Maybe I picked bad ones, maybe I didn't really know what I was expecting!
But I'd like to know if there are any 'standard' profilers which simply drop in and work? I don't believe I need massively fine-detailed reports, just to pick up major black-spots. Ease of use is more important to me at this point.

It's VC++ 2008 we're using (I run standard edition personally). I don't suppose there are any tools in the IDE for this, I can't see any from looking at the main menus?

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

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

发布评论

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

评论(6

安静 2024-09-04 18:29:16

我建议一个非常简单的方法(我从阅读 Mike Dunlavey 的帖子中学到的):

只需暂停程序。

重复几次以获得合理的样本。如果某个特定函数占用了程序执行时间的一半,那么您很可能很快就会发现它。

如果将该函数的性能提高 50%,那么整体执行时间就缩短了 25%。如果您发现根本不需要它(我在使用此方法的短时间内就发现了几个这样的情况),那么您就将执行时间减少了一半。

我必须承认,起初我对这种方法的功效相当怀疑,但尝试了几周后,我就着迷了。

I suggest a very simple method (which I learned from reading Mike Dunlavey's posts on SO):

Just pause the program.

Do it several times to get a reasonable sample. If a particular function is taking half of your program's execution time, the odds are that you will catch it in the act very quickly.

If you improve that function's performance by 50%, then you've just improved overall execution time by 25%. And if you discover that it's not even needed at all (I have found several such cases in the short time I've been using this method), you've just cut the execution time in half.

I must confess that at first I was quite skeptical of the efficacy of this approach, but after trying it for a couple of weeks, I'm hooked.

万劫不复 2024-09-04 18:29:16

内置VS:

如果您有团队版本,您可以使用Visual Studio 分析器


其他选项:

否则请检查此线程


轻松创建自己的:

我个人使用基于 Win32 API 的内部构建的 API 查询性能计数器
您可以在一百行或更少的代码内制作出漂亮且易于使用的东西。

该过程很简单:在您想要分析的每个函数的顶部创建一个名为 PROFILE_FUNC() 的宏,并将其添加到内部管理的统计信息中。然后有另一个名为 PROFILE_DUMP() 的宏,它将输出转储到文本文档。

PROFILE_FUNC() 创建一个对象,该对象将使用 RAII 记录该对象被销毁之前的时间量。此 RAII 对象的构造函数和析构函数都将调用 QueryPerformanceCounter。您还可以将这些行保留在代码中,并通过 #define PROFILING_ON 控制行为

VS built in:

If you have team edition you can use the Visual Studio profiler.


Other options:

Otherwise check this thread.


Creating your own easily:

I personally use an internally built one based on the Win32 API QueryPerformanceCounter.
You can make something nice and easy to use within a hundred lines of code or less.

The process is simple: create a macro at the top of each function that you want to profile called PROFILE_FUNC() and that will add to internally managed stats. Then have another macro called PROFILE_DUMP() which will dump the outputs to a text document.

PROFILE_FUNC() creates an object that will use RAII to log the amount of time until the object is destroyed. Both the constructor of this RAII object and the destructor will call QueryPerformanceCounter. You could also leave these lines in your code and control the behavior via a #define PROFILING_ON

残花月 2024-09-04 18:29:16

我一直使用 AMD CodeAnalyst,我发现它非常易于使用并且给出了有趣的结果。我总是使用基于时间的配置文件,我发现它与我的应用程序的调试信息配合得很好,让我可以找到在过程、C++ 指令和单个汇编指令级别上花费时间的地方。

I always used AMD CodeAnalyst, I find it quite easy to use and gives interesting results. I always used the time based profile, in which I found that it cooperates well with my apps' debug information, letting me find where the time is spent at procedure, C++ instruction and single assembly instruction level.

浮光之海 2024-09-04 18:29:16

我过去使用 lt prof 来快速运行我的 C++ 应用程序。它工作起来非常简单,可以使用编译后的程序运行,不需要源代码挂钩或调整。我相信有一个试用版。

I used lt prof in the past for a quick run down of my C++ app. It works pretty easy and runs with a compiled program, does not need and source code hooks or tweaks. There is a trial version available I believe.

↘紸啶 2024-09-04 18:29:16

一种非常简单(且免费)的分析方法是安装 Windows 调试器 (cdb/windbg),在感兴趣的位置设置 bp,然后发出 wt 命令(“跟踪和观察数据”) )。请查看 MSDN 了解更多信息。

A very simple (and free) way to profile is to install the Windows debuggers (cdb/windbg), set a bp on the place of interest, and issue the wt command ("Trace and Watch Data"). Check out MSDN for more info.

流绪微梦 2024-09-04 18:29:16

另一个适用于任何编程语言的超级简单且有用的分析工作流程是注释掉代码块。注释掉所有这些之后,取消注释一些并运行您的程序以查看性能。如果当某些代码被取消注释时您的程序开始运行非常慢,那么您可能需要检查那里的性能。

Another super simple and useful profiling workflow that works on any programming languages is to comment out blocks of codes. After commenting out all of them, uncomment some and run your program to see the performance. If your program starts to run very slow when some code has been uncommented, then you'll probably want to check the performance there.

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