优化:用于 Visual Studio 的 gprof 等工具
作为一名 C# 程序员,我正处于从小项目到中型项目的过渡中。我以前的小项目不需要分析器。但现在我需要一个工具来帮助我提高代码的性能。我很多年前在 C 语言中使用过 gprof。
有人可以给我一个起点,或者推荐我一个像 VS2008 的 gprof 这样的工具吗?那就是:一个统计每个函数被调用了多少次,以及每个函数花费了多少时间的工具。无论是否必须付费(在某些限制下)。
关于如何找到应该优化的代码部分的任何其他建议都会很棒。
谢谢。
As a C# programmer, i'm in a transition from small projects to medium projects. I didn't need a profiler for my little projects before. But now I need a tool that help me improving the performance of my code. I used gprof many years ago, in C.
Can someone give me a starting point, or recommend me a tool like gprof for VS2008? That is: A tool that counts how many times every function has been called, and how many time It's spended in every function. No matter if a had to pay for it (under certains limits).
Any other advice about how to locate portions of code that should be optimized will be great.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看 Ants 分析器
Check out the Ants profiler
Visual Studio 内置了此功能,具体取决于您使用的版本。在专业版(我相信)中,您有“分析”部分,它可以为您提供函数内的计时,包括和不包括进一步的调用、调用次数等...
它通常位于“分析”菜单选项(如果有)下。
EDIT
VS2010 对此也有了很大的改进。具有一些非常酷的多线程性能分析,向您展示线程花费时间执行/阻塞的操作类型。它还显示了我相信在您的代码中的逐行计时(当然我看到的最后一个屏幕截图也是如此)。
Visual Studio has this functionality built in depending on the version you are using. Within Professional (I believe), you have the Profiling section which gives you timing within functions inclusive and exclusive of further calls, # of calls etc...
It is normally located under the 'Analyze' menu option if it's there.
EDIT
Come VS2010 this has also been greatly improved. Featuring some very cool looking multi-threaded performance analysis, showing you what sort of operations the thread spends its time doing/blocking on. It also displays line by line timings I believe within your code (certainly the last screenshot I saw did).
您可以比 gprof 或任何类似的东西做得更好。
这里有一个简单的解释,包括指向原始的gprof论文,以及对其作用和不作用的解释。
这是一个示例。
You can do better than gprof or anything that acts like it.
Here's a quick-and-dirty explanation, including a link to the original gprof paper, and an explanation of what it does and does not do.
Here's an example.
我使用过 DotTrace 和 AQTime 两者都易于使用和理解。
I've used DotTrace and AQTime both are easy to use and understand.