C# 如何在 Visual Studio 2008“Pro”中进行性能分析
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/573050/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How To Do Performance Profiling in Visual Studio 2008 "Pro"
提问by Brock Woolf
Microsoft make this piece of software called "Visual Studio 2008 Professional". I have found that there doesn't appear to be an application performance profiler or something similar in it, making it seem not so "professional" to me.
微软制作了一款名为“Visual Studio 2008 Professional”的软件。我发现似乎没有应用程序性能分析器或类似的东西,使它对我来说似乎不是那么“专业”。
If Microsoft don't include a profiler, what are your third party options for time profiling for Visual Studio 2008? Free would be preferable, as this is for uni student purposes :P
如果 Microsoft 不包含分析器,那么您的 Visual Studio 2008 时间分析的第三方选项是什么?免费会更可取,因为这是为了单学生目的:P
采纳答案by Alun Harford
Personally, I use the Red Gate profiler.
就个人而言,我使用 Red Gate 分析器。
Others swear by the JetBrains one.
其他人则对 JetBrains 发誓。
Those seem to be the options, and there isn't much between them.
这些似乎是选项,它们之间没有太多选择。
回答by dmajkic
RedGate ANTS profileris not that expensive, and does the job.
RedGate ANTS 分析器并不那么昂贵,并且可以完成这项工作。
回答by Otávio Décio
I use JetBrain's dotTrace and it works quite well.
我使用 JetBrain 的 dotTrace 并且效果很好。
回答by dirkgently
I use the Team System Edition. That comes with a profiler which is pretty good. There are other options out there:
我使用的是团队系统版。它带有一个非常好的分析器。还有其他选择:
- Rational Purify(there's this PurifyPlus, but dunno much)
- Intel Vtune
- Rational Purify(有这个 PurifyPlus,但不太清楚)
- 英特尔 Vtune
Hope that helps. Note: None of them are free.
希望有帮助。注意:它们都不是免费的。
Happy profiling :)
快乐的分析:)
回答by Jon Skeet
I use JetBrains dotTrace profiler. This is a commercial profiler. (Full disclosure: I receive a free licence as an MVP. It hasproved very useful though.)
我使用JetBrains dotTrace 分析器。这是一个商业分析器。(全面披露:我收到一个免费的许可证作为MVP它。已经证明,虽然是非常有用的。)
There's also the free CLR Profiler for .NET 2.0and an article explaining how to use it.
回答by Kris Erickson
There are a couple of free profilers, not as complete or polished as the commercial ones, but they can definately help a lot:
有几个免费的分析器,不像商业分析器那样完整或完善,但它们绝对可以提供很多帮助:
Eqatec- This was designed for Windows CE, but works just fine for normal applications.
Eqatec- 这是为 Windows CE 设计的,但对于普通应用程序来说效果很好。
Soft Prodigy Profile Sharp- This is actually an open source project written in c#, so you can tinker with it if you want.
Soft Prodigy Profile Sharp- 这实际上是一个用 c# 编写的开源项目,因此您可以根据需要修改它。
回答by Mike Dunlavey
Re-edited: You asked what your options were. If your heart is set on profiling, then look for a profiler.
重新编辑:你问你的选择是什么。如果您的心是分析,那么寻找分析器。
On the other hand, if you actually have a performance problem to find, the simple method works as well or better than nearly every profiler. I say nearly every, because in some profilers you can actually tease out what you need to know, which is the time-cost attributable to individual instructions, especially call instructions.
另一方面,如果您确实需要查找性能问题,那么这种简单方法的效果与几乎所有分析器一样好,甚至更好。我说几乎所有,因为在一些分析器中,您实际上可以梳理出您需要知道的内容,这是归因于单个指令的时间成本,尤其是调用指令。
The time-cost of an instruction is the amount of time that would be saved if the instruction could be removed, and a good estimate of it is the fraction of call stack samples containing it. You don't need to estimate that fraction with high precision. If the instruction is on 5 out of 10 samples, it's cost is probably somewhere in the range 45% to 55%. No matter - if you could get rid of it, you would save its cost.
一条指令的时间成本是如果可以删除该指令将节省的时间量,对它的一个很好的估计是包含它的调用堆栈样本的比例。您不需要以高精度估计该分数。如果指令针对 10 个样本中的 5 个,则其成本可能在 45% 到 55% 之间。无论如何 - 如果你能摆脱它,你会节省它的成本。
So finding performance problems is not hard. Just take a number of call stack samples, collect the set of instructions on those samples, and rank the instructions by the fraction of samples containing them. Among the high-fraction instructions are some that you could optimize away, and you don't have to guess where they are.
所以发现性能问题并不难。只需取一些调用堆栈样本,收集这些样本上的指令集,然后按包含它们的样本的比例对指令进行排序。在高分指令中有一些您可以优化掉,而且您不必猜测它们在哪里。
I'm simplifying somewhat, because often it is helpful to examine more state information than just the call stack, to see if some work being done is really necessary. But I hope the point is made.
我稍微简化了一些,因为检查更多的状态信息而不只是调用堆栈通常会很有帮助,以查看是否真的需要完成某些工作。但我希望这一点得到了证实。
People express doubt that it could work in the presence of recursion, or work on large programs. A little thought (and experimentation) shows those objections do not hold water.
人们表示怀疑它是否可以在存在递归的情况下工作,或者在大型程序上工作。一点想法(和实验)表明这些反对意见站不住脚。
回答by Gary
Download the VS 2008 stand alone command line profiler http://www.microsoft.com/downloads/details.aspx?familyid=fd02c7d6-5306-41f2-a1be-b7dcb74c9c0b&displaylang=en
下载 VS 2008 独立命令行分析器 http://www.microsoft.com/downloads/details.aspx?familyid=fd02c7d6-5306-41f2-a1be-b7dcb74c9c0b&displaylang=en