寻找应用程序的瓶颈

发布于 2024-09-15 14:21:40 字数 127 浏览 6 评论 0原文

我有一个 .NET 应用程序,它快速运行大约 2000 条记录,但开始变得非常慢。我正在尝试找到瓶颈,我想知道是否有一个好的,可能是免费的,但不一定是工具或方法来找到瓶颈。我试图找到一个尚未清除的列表,但我还没有看到它。我有VS 2008。

I have an .NET app and it runs fast through about 2000 records that starts to go really slow. I'm trying to find the bottleneck and I was wondering if there is a good, possibly free but it doesn't have to be, tool or a way to find the bottleneck. I'm trying to find a list that isn't cleared out but I don't see it yet. I have VS 2008.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

吖咩 2024-09-22 14:21:40

您可能想要开始运行一些性能计数器 监控 CPU 使用率和内存统计数据并了解发生了什么情况。

如果这没有给您带来任何明显的答案,那么是时候开始分析了。

JetBrains dotTrace 有 30 天免费试用期。这是一个相当不错的内存和性能分析器,您可能想检查一下。

Microsoft 的 CLR 探查器 是免费的。

如果您仍然一无所获,那么是时候拿出大招了:WinDbg。如果您到目前为止,您会发现 Tess 的博客非常有帮助。

You may want to start running some performance counters to monitor CPU usage and memory stats and figure out what's going on.

If that doesn't lead you to any obvious answers, it's time to start profiling.

JetBrains dotTrace has a 30 day free trial. It's a pretty decent memory and performance profiler you might want to check out.

Microsoft's CLR Profiler is free.

If you're still coming up with nothing, it's time to break out the big guns: WinDbg. If you get this far, you'll find Tess' blog extremely helpful.

醉殇 2024-09-22 14:21:40

有一个非常好的免费工具,而且您已经拥有了。它唯一的缺点是它一开始可能不直观。

当程序运行缓慢时,在IDE下暂停它。检查调用堆栈。 (我关闭了参数的显示;我只对特定的代码行感兴趣。我将整个堆栈复制到文本编辑器,如记事本。)这样做几次。速度越慢,您在发现问题之前需要的样本就越少。

如果您看到一个或多个可疑的流行陈述,例如它们出现在健康样本中(至少两个),您应该注意这些。我所做的就是再采集一些样本,直到它们出现为止,因为我想了解它们为何被处决。这很重要,因为如果我可以用花费更少时间的东西来代替它们,我将节省很大一部分。

我将尝试解释它为什么有效。
首先,“瓶颈”这一常见概念存在严重误导。
软件并不慢,因为它有限制或“热点”地方。
当然也可能有缓存未命中等情况,但主要原因是
它之所以慢,是因为它做的事情超出了它需要做的事情——通常多了很多

它会在疯狂的嵌套函数调用中介中发生,
理由越来越遥远。
这显示为一个比必要的更加茂密的调用树。
您所要做的就是找到可以修剪的大树枝。
这就是暂停技术的作用。

因此,当您四处寻找可以帮助您扮演侦探来找到难以捉摸的“瓶颈”的工具时,请成为一名树木外科医生,并从调用树中修剪掉最重的树枝(通过暂停发现),然后继续这样做直到你不能为止。

持怀疑态度是件好事,但你可能会惊讶于它的效果如何。

There is a very good free tool, and you already have it. It's only disadvantage is that it may not be intuitive, to begin with.

When the program is acting slow, pause it under the IDE. Examine the call stack. (I turn off the display of arguments; I'm only interested in the specific lines of code. I copy the whole stack out to a text editor, like notepad.) Do this several times. The slower it is, the fewer samples you're going to need before you see the problem.

If you see one or more statements that are suspiciously popular, like they appear on a healthy fraction of samples (at least two), you should pay attention to those. What I do is take a few more samples until they show up, because I want to understand why they are being executed. That's important, because if I could replace them by something that took a lot less time, I would save a large fraction.

I'll try to explain why it works.
First, the common concept of "bottleneck" is seriously misleading.
Software isn't slow because it has constrictions or "hot" places.
Of course it can have cache misses and so on, but the dominant reason
it is slow is that it is doing more than it needs to - often a lot more.

It goes off on wild nested function call junkets,
with justifications more and more remote.
This shows up as a call tree that is far more bushy than necessary.
All you have to do is find big branches that you can prune off.
That is what the pausing technique does.

So while you're rummaging around for the tool that will help you play detective to locate the elusive "bottleneck", be a tree surgeon, and prune the heaviest branches you can from the call tree, as found by pausing, and keep doing it until you can't.

It's good to be skeptical, but you may be surprised how well it works.

眉黛浅 2024-09-22 14:21:40

Adam Calderon 的此页面链接到一些 MSDN 博客有关分析的页面。

然而,其中大多数(如果不是全部)似乎都与 Visual Studio Team System 有关。因此,如果您可以访问该版本的软件,您就可以“免费”获得一些工具。

This page from Adam Calderon links to some MSDN blog pages on profiling.

However, most (if not all) of them seem to be about Visual Studio Team System. So if you have access to that version of the software you get some tools "for free".

喜爱纠缠 2024-09-22 14:21:40

DevPartner for C++ 我的 MicroFocus(以前称为 Compuware)有一个还算不错的性能分析器。
Intel 制作的 V-Tune 也能起到同样的作用。 (我认为是英特尔......我从未使用过它)。
我最喜欢的是 Visual Studio Team Edition 附带的那个。这很棒。
您还应该检测自己的代码,并编写自动化测试,以便可以将一个构建与下一个构建进行比较。

DevPartner for C++ my MicroFocus (Formerly Compuware) has a performance profiler that was halfway decent.
Intel makes V-Tune that does the same thing. ( I think it's Intel... I've never used it).
My favorite is the one that comes with Visual Studio Team Edition. It's great.
You should also instrument your own code, and write automated tests as well so you can compare one build to the next.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文