调试性能问题的最佳方法是什么? [英] What is the best way to debug performance problems?

查看:43
本文介绍了调试性能问题的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用C#.NET编写另一个程序的插件,并且遇到性能问题,命令花费的时间比我要长得多.该插件对主机程序中的事件做出反应,并且还取决于主机程序SDK的实用程序方法.我的插件具有很多递归功能,因为我正在对树结构进行大量读取和写入.另外,我的插件和主机应用程序之间有很多事件订阅,插件中的类之间也有事件订阅.

I'm writing a plug-in for another program in C#.NET, and am having performance issues where commands take a lot longer then I would. The plug-in reacts to events in the host program, and also depends on utility methods of the the host program SDK. My plug-in has a lot of recursive functions because I'm doing a lot of reading and writing to a tree structure. Plus I have a lot of event subscriptions between my plugin and the host application, as well as event subscriptions between classes in my plug-in.

我如何确定完成任务需要这么长时间?我不能使用常规的断点样式调试,因为不是因为它不起作用而是因为它太慢了.我已经设置了一个静态的"LogWriter"类,我可以从所有类中引用该类,从而使我可以从代码中将带时间戳的行写到日志文件中.还有另一种方法吗?Visual Studio是否保留我可以使用的带有时间戳记的日志?在应用程序关闭后,可以通过某种方式查看调用堆栈吗?

How can I figure out what is taking so long for a task to complete? I can't use regular breakpoint style debugging, because it's not that it doesn't work it's just that it's too slow. I have setup a static "LogWriter" class that I can reference from all my classes that will allow me to write out timestamped lines to a log file from my code. Is there another way? Does visual studio keep some kind of timestamped log that I could use instead? Is there someway to view the call stack after the application has closed?

推荐答案

您需要使用分析器.这里链接到好人: ANTS Performance Profiler .

You need to use profiler. Here link to good one: ANTS Performance Profiler.

更新:您还可以使用 DebugView 应用程序,该应用程序将精确显示所有调试字符串时间戳记.它是免费软件,非常适合快速调试和分析.

Update: You can also write messages in control points using Debug.Write. Then you need to load DebugView application that displays all your debug string with precise time stamp. It is freeware and very good for quick debugging and profiling.

这篇关于调试性能问题的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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