如何衡量C ++(MFC)应用程序的性能?

时间:2022-05-22 04:10:01

What good profilers do you know?

你知道什么好的个人资料?

What is a good way to measure and tweak the performance of a C++ MFC application?

测量和调整C ++ MFC应用程序性能的好方法是什么?

Is Analysis of algorithms really neccesary? http://en.wikipedia.org/wiki/Algorithm_analysis

算法的分析真的是必要的吗? http://en.wikipedia.org/wiki/Algorithm_analysis

10 个解决方案

#1


4  

I strongly recommend AQTime if you are staying on the Windows platform. It comes with a load of profilers, including static code analysis, and works with most important Windows compilers and systems, including Visual C++, .NET, Delphi, Borland C++, Intel C++ and even gcc. And it integrates into Visual Studio, but can also be used standalone. I love it.

如果你在Windows平台上,我强烈推荐AQTime。它配备了大量的分析器,包括静态代码分析,并与最重要的Windows编译器和系统一起使用,包括Visual C ++,.NET,Delphi,Borland C ++,Intel C ++甚至gcc。它集成到Visual Studio中,但也可以单独使用。我喜欢它。

#2


2  

If you're (still) using Visual C++ 6.0, I suggest using the built-in profiler. For more recent versions you could try Compuware DevPartner Performance Analysis Community Edition.

如果您(仍)使用Visual C ++ 6.0,我建议使用内置的分析器。对于更新版本,您可以尝试使用Compuware DevPartner Performance Analysis Community Edition。

#3


2  

For Windows, check out Xperf which ships free 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。它使用采样配置文件,具有一些有用的UI,并且不需要检测。对于跟踪性能问题非常有用。你可以回答以下问题:

Who is using the most CPU? Drill down to function name using call stacks. Who is allocating the most memory? Who is doing the most registry queries? Disk writes? etc. You will be quite surprised when you find the bottlenecks, as they are probably not where you expected!

谁使用最多的CPU?使用调用堆栈深入查看函数名称。谁分配的内存最多?谁在进行大多数注册表查询?磁盘写道?当你发现瓶颈时,你会感到非常惊讶,因为它们可能不是你想象的那样!

#4


1  

It's been a while since I profiled unmanaged code, but when I did I had good results with Intel's vtune. I'm sure somebody else will tell us if that's been overtaken.

自从我分析了非托管代码以来已经有一段时间了,但是当我这样做时,我在英特尔的vtune上取得了不错的成绩。我相信别人会告诉我们这是否被超越了。

Algorithmic analysis has the potential to improve your performance more profoundly than anything you'll find with a profiler, but only for certain classes of application. If you operate over reasonably large sets of data, algorithmic analysis might find ways to be more efficient in CPU/Memory/both, but if your app is mainly form-fill with a relational database for storage, it might not offer you much.

算法分析有可能比使用分析器找到的任何东西更深刻地改善您的性能,但仅适用于某些类别的应用程序。如果您对相当大的数据集进行操作,算法分析可能会找到提高CPU /内存/两者的效率的方法,但如果您的应用程序主要使用关系数据库进行表单填充以进行存储,则可能不会为您提供太多帮助。

#5


1  

Intel Thread Checker via Vtune performance analyzer- Check this picture for the view i use the most that tells me which function eats up the most of my time.

英特尔线程检查器通过Vtune性能分析器 - 检查此图片以查看我使用最多的视图,告诉我哪个功能占用了我的大部分时间。

如何衡量C ++(MFC)应用程序的性能?

I can further drill down inside and decompose which functions inside them eats up more time etc. There are different views based on what you are watching (total time = time within fn + children), self time (time spent only in code running inside the function etc).

我可以进一步深入内部并分解其中的哪些功能会占用更多时间等。根据您正在观看的内容(总时间= fn +儿童中的时间),自我时间(仅在代码内部运行的时间),有不同的视图功能等)。

This tool does a lot more than profiling but i haven't explored them all. I would definitely recommend it. The tool is also available for downloading as a fully functional trial version that can run for 30 days. If you have cost constraints, i would say this window is all that you require to pin point your problem.

这个工具比分析更多,但我还没有探索过它们。我肯定会推荐它。该工具也可作为可运行30天的全功能试用版下载。如果您有成本限制,我会说这个窗口就是您需要确定问题所需的全部内容。

Trial download here - https://registrationcenter.intel.com/RegCenter/AutoGen.aspx?ProductID=907&AccountID=&ProgramID=&RequestDt=&rm=EVAL&lang=

试用版下载 - https://registrationcenter.intel.com/RegCenter/AutoGen.aspx?ProductID=907&AccountID=&ProgramID=&RequestDt=&rm=EVAL&lang=

ps : I have also played with Rational Rational but for some reason I did not take much to it. I suspect Rational might be more expensive than Intel too.

ps:我也玩过Rational Rational,但出于某种原因,我并没有花太多时间。我怀疑Rational也可能比英特尔更贵。

#6


1  

Tools (like true time from DevPartner) that let you see hit counts for source lines let you quickly find algorithms that have bad 'Big O' complexity. You still have to analyse the algorithm to determine how to reduce the complexity.

通过工具(如DevPartner的真实时间),您可以查看源行的命中数,这样您就可以快速找到具有“Big O”错误的算法。您仍然需要分析算法以确定如何降低复杂性。

#7


1  

I second AQTime, having both AQTime and Compuwares DevPartner, for most cases. The reason being that AQTime will profile any executable that has a valid PDB file, whereas TrueTime requires you to make an instrumented build. This greatly speeds up and simplifies ad hoc profiling. DevPartner is also quite a bit more expensive if this is an issue. Where DevPartner comes into its own is with BoundsChecker, which I still rate as a better tool for catching leaks and overwrites than AQTimes execution profiler. TrueTime can be slighly more accurate than AQTime, but I have never found this to be an issue.

在大多数情况下,我的第二个AQTime,包括AQTime和Compuwares DevPartner。原因是AQTime将分析具有有效PDB文件的任何可执行文件,而TrueTime要求您进行检测构建。这极大地加速并简化了临时分析。如果这是一个问题,DevPartner也会相当昂贵。 DevPartner自成一体的地方就是BoundsChecker,我仍然认为这是一个比AQTimes执行分析器更好的捕获泄漏和覆盖的工具。 TrueTime可以比AQTime更精确,但我从来没有发现这是一个问题。

Is profiling worthwhile, IMO yes, if you need performance gains on a local application. I think you also learn a lot about how your program and algorithms really work, and the cost implications of using certain types of object classes for storing and iterating through your data.

如果您需要在本地应用程序上获得性能提升,那么分析是否值得,IMO是的。我想你也学到了很多关于你的程序和算法是如何工作的,以及使用某些类型的对象类来存储和迭代数据的成本含义。

#8


0  

Glowcode is a very nice profiler (when it works). It can attach to a running program and requires only symbol files - you don't need to rebuild.

Glowcode是一个非常好的分析器(当它工作时)。它可以附加到正在运行的程序,只需要符号文件 - 您不需要重建。

#9


0  

Some versions pf visual studio 2005 (and maybe 2008) actually come with a pretty good performance profiler.
if you have it it should be available under the tools menu
or you can search for a way to open the "performance explorer" window to start a new performance session.
A link to MSDN

有些版本的视觉工作室2005(也许是2008年)实际上有一个非常好的性能分析器。如果您拥有它,它应该在工具菜单下可用,或者您可以搜索打开“性能浏览器”窗口以启动新的性能会话的方法。 MSDN的链接

#10


0  

FYI, Some versions of Visual Studio only come with a non-optimizing compiler. For one of my my MFC apps if I compile it with MINGW/MSYS ( gcc compiler ) with -o3 then it runs about 5-10x as fast as my release compile with Visual Studio.

仅供参考,某些版本的Visual Studio只带有非优化编译器。对于我的一个MFC应用程序,如果我使用MINGW / MSYS(gcc编译器)使用-o3进行编译,那么它的运行速度大约是我使用Visual Studio编译版本的5-10倍。

For example I have an openstreetmap xml compiler and it takes about 3 minutes ( the gcc compiled version) to process a 2.7GB xml file. My visual studio compile of the same code takes about 18 minutes to run.

例如,我有一个openstreetmap xml编译器,它需要大约3分钟(gcc编译版本)来处理一个2.7GB的xml文件。我的Visual Studio编译相同的代码大约需要18分钟才能运行。

#1


4  

I strongly recommend AQTime if you are staying on the Windows platform. It comes with a load of profilers, including static code analysis, and works with most important Windows compilers and systems, including Visual C++, .NET, Delphi, Borland C++, Intel C++ and even gcc. And it integrates into Visual Studio, but can also be used standalone. I love it.

如果你在Windows平台上,我强烈推荐AQTime。它配备了大量的分析器,包括静态代码分析,并与最重要的Windows编译器和系统一起使用,包括Visual C ++,.NET,Delphi,Borland C ++,Intel C ++甚至gcc。它集成到Visual Studio中,但也可以单独使用。我喜欢它。

#2


2  

If you're (still) using Visual C++ 6.0, I suggest using the built-in profiler. For more recent versions you could try Compuware DevPartner Performance Analysis Community Edition.

如果您(仍)使用Visual C ++ 6.0,我建议使用内置的分析器。对于更新版本,您可以尝试使用Compuware DevPartner Performance Analysis Community Edition。

#3


2  

For Windows, check out Xperf which ships free 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。它使用采样配置文件,具有一些有用的UI,并且不需要检测。对于跟踪性能问题非常有用。你可以回答以下问题:

Who is using the most CPU? Drill down to function name using call stacks. Who is allocating the most memory? Who is doing the most registry queries? Disk writes? etc. You will be quite surprised when you find the bottlenecks, as they are probably not where you expected!

谁使用最多的CPU?使用调用堆栈深入查看函数名称。谁分配的内存最多?谁在进行大多数注册表查询?磁盘写道?当你发现瓶颈时,你会感到非常惊讶,因为它们可能不是你想象的那样!

#4


1  

It's been a while since I profiled unmanaged code, but when I did I had good results with Intel's vtune. I'm sure somebody else will tell us if that's been overtaken.

自从我分析了非托管代码以来已经有一段时间了,但是当我这样做时,我在英特尔的vtune上取得了不错的成绩。我相信别人会告诉我们这是否被超越了。

Algorithmic analysis has the potential to improve your performance more profoundly than anything you'll find with a profiler, but only for certain classes of application. If you operate over reasonably large sets of data, algorithmic analysis might find ways to be more efficient in CPU/Memory/both, but if your app is mainly form-fill with a relational database for storage, it might not offer you much.

算法分析有可能比使用分析器找到的任何东西更深刻地改善您的性能,但仅适用于某些类别的应用程序。如果您对相当大的数据集进行操作,算法分析可能会找到提高CPU /内存/两者的效率的方法,但如果您的应用程序主要使用关系数据库进行表单填充以进行存储,则可能不会为您提供太多帮助。

#5


1  

Intel Thread Checker via Vtune performance analyzer- Check this picture for the view i use the most that tells me which function eats up the most of my time.

英特尔线程检查器通过Vtune性能分析器 - 检查此图片以查看我使用最多的视图,告诉我哪个功能占用了我的大部分时间。

如何衡量C ++(MFC)应用程序的性能?

I can further drill down inside and decompose which functions inside them eats up more time etc. There are different views based on what you are watching (total time = time within fn + children), self time (time spent only in code running inside the function etc).

我可以进一步深入内部并分解其中的哪些功能会占用更多时间等。根据您正在观看的内容(总时间= fn +儿童中的时间),自我时间(仅在代码内部运行的时间),有不同的视图功能等)。

This tool does a lot more than profiling but i haven't explored them all. I would definitely recommend it. The tool is also available for downloading as a fully functional trial version that can run for 30 days. If you have cost constraints, i would say this window is all that you require to pin point your problem.

这个工具比分析更多,但我还没有探索过它们。我肯定会推荐它。该工具也可作为可运行30天的全功能试用版下载。如果您有成本限制,我会说这个窗口就是您需要确定问题所需的全部内容。

Trial download here - https://registrationcenter.intel.com/RegCenter/AutoGen.aspx?ProductID=907&AccountID=&ProgramID=&RequestDt=&rm=EVAL&lang=

试用版下载 - https://registrationcenter.intel.com/RegCenter/AutoGen.aspx?ProductID=907&AccountID=&ProgramID=&RequestDt=&rm=EVAL&lang=

ps : I have also played with Rational Rational but for some reason I did not take much to it. I suspect Rational might be more expensive than Intel too.

ps:我也玩过Rational Rational,但出于某种原因,我并没有花太多时间。我怀疑Rational也可能比英特尔更贵。

#6


1  

Tools (like true time from DevPartner) that let you see hit counts for source lines let you quickly find algorithms that have bad 'Big O' complexity. You still have to analyse the algorithm to determine how to reduce the complexity.

通过工具(如DevPartner的真实时间),您可以查看源行的命中数,这样您就可以快速找到具有“Big O”错误的算法。您仍然需要分析算法以确定如何降低复杂性。

#7


1  

I second AQTime, having both AQTime and Compuwares DevPartner, for most cases. The reason being that AQTime will profile any executable that has a valid PDB file, whereas TrueTime requires you to make an instrumented build. This greatly speeds up and simplifies ad hoc profiling. DevPartner is also quite a bit more expensive if this is an issue. Where DevPartner comes into its own is with BoundsChecker, which I still rate as a better tool for catching leaks and overwrites than AQTimes execution profiler. TrueTime can be slighly more accurate than AQTime, but I have never found this to be an issue.

在大多数情况下,我的第二个AQTime,包括AQTime和Compuwares DevPartner。原因是AQTime将分析具有有效PDB文件的任何可执行文件,而TrueTime要求您进行检测构建。这极大地加速并简化了临时分析。如果这是一个问题,DevPartner也会相当昂贵。 DevPartner自成一体的地方就是BoundsChecker,我仍然认为这是一个比AQTimes执行分析器更好的捕获泄漏和覆盖的工具。 TrueTime可以比AQTime更精确,但我从来没有发现这是一个问题。

Is profiling worthwhile, IMO yes, if you need performance gains on a local application. I think you also learn a lot about how your program and algorithms really work, and the cost implications of using certain types of object classes for storing and iterating through your data.

如果您需要在本地应用程序上获得性能提升,那么分析是否值得,IMO是的。我想你也学到了很多关于你的程序和算法是如何工作的,以及使用某些类型的对象类来存储和迭代数据的成本含义。

#8


0  

Glowcode is a very nice profiler (when it works). It can attach to a running program and requires only symbol files - you don't need to rebuild.

Glowcode是一个非常好的分析器(当它工作时)。它可以附加到正在运行的程序,只需要符号文件 - 您不需要重建。

#9


0  

Some versions pf visual studio 2005 (and maybe 2008) actually come with a pretty good performance profiler.
if you have it it should be available under the tools menu
or you can search for a way to open the "performance explorer" window to start a new performance session.
A link to MSDN

有些版本的视觉工作室2005(也许是2008年)实际上有一个非常好的性能分析器。如果您拥有它,它应该在工具菜单下可用,或者您可以搜索打开“性能浏览器”窗口以启动新的性能会话的方法。 MSDN的链接

#10


0  

FYI, Some versions of Visual Studio only come with a non-optimizing compiler. For one of my my MFC apps if I compile it with MINGW/MSYS ( gcc compiler ) with -o3 then it runs about 5-10x as fast as my release compile with Visual Studio.

仅供参考,某些版本的Visual Studio只带有非优化编译器。对于我的一个MFC应用程序,如果我使用MINGW / MSYS(gcc编译器)使用-o3进行编译,那么它的运行速度大约是我使用Visual Studio编译版本的5-10倍。

For example I have an openstreetmap xml compiler and it takes about 3 minutes ( the gcc compiled version) to process a 2.7GB xml file. My visual studio compile of the same code takes about 18 minutes to run.

例如,我有一个openstreetmap xml编译器,它需要大约3分钟(gcc编译版本)来处理一个2.7GB的xml文件。我的Visual Studio编译相同的代码大约需要18分钟才能运行。