什么非常简单的C++ Profiler(vc++)?

发布于 2025-02-10 13:48:16 字数 190 浏览 1 评论 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

峩卟喜欢 2025-02-17 13:48:16

(我从阅读 Mike Dunlavey 上的帖子):

我建议一种非常简单的方法 程序。

做几次获取合理的样本。如果特定功能占据了程序的执行时间的一半,则几率是您将很快在ACT中捕获它。

如果您将该功能的性能提高了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.

琴流音 2025-02-17 13:48:16

vs内置:

如果您有团队版本,则可以使用 Visual Studio Profiler


其他选项:

否则检查此线程


很容易创建自己的:

我个人使用了基于Win32 API queryperformancecounter
您可以在一百条代码或更少的一百行代码中制作一些易于使用的东西。

该过程很简单:在要配置文件的每个函数的顶部创建一个宏,并将添加到内部管理的统计数据中。然后,还有另一个称为profile_dump()的宏,该宏将将输出转换为文本文档。

profile_func()创建一个对象,该对象将使用RAII记录直到对象被破坏为止的时间。此RAII对象的构造函数和驱动器都将调用QueryPerformanceCounter。您也可以将这些行留在代码中,并通过#Define Propiling_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

只是在用心讲痛 2025-02-17 13:48: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.

━╋う一瞬間旳綻放 2025-02-17 13:48: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.

混吃等死 2025-02-17 13:48:16

一个非常简单的(免费)简单的方法是安装Windows Debugger(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.

如日中天 2025-02-17 13:48: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 和您的相关数据。
原文