什么是非常容易的C ++ profiler(VC ++)? [英] What's a very easy C++ profiler (VC++)?

查看:234
本文介绍了什么是非常容易的C ++ profiler(VC ++)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在过去使用过几个剖析器,从来没有发现它们特别容易。也许我选错了,也许我真的不知道我的期望!
但是我想知道是否有任何标准的剖析器,简单地放入和工作?我不相信我需要大量细致的报告,只是为了找到主要的黑点。在这一点上,易用性对我来说更重要。

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.

这是VC ++ 2008,我们使用(我个人运行标准版)。

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?

推荐答案

VS内置:

VS built in:

如果您有团队版,可以使用 Visual Studio profiler

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

其他选项:

否则检查此线程

轻松创建自己的

我亲自使用基于Win32 API的内部版本 QueryPerformanceCounter
你可以在一百行代码或更少的代码中做出一些漂亮和容易使用的东西。

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.

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

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()创建一个对象,它将使用RAII记录对象被销毁之前的时间。这个RAII对象的构造函数和析构函数将调用 QueryPerformanceCounter 。您还可以在代码中保留这些行,并通过 #define PROFILING_ON

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

这篇关于什么是非常容易的C ++ profiler(VC ++)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆