调试性能问题的最佳方法是什么?

编程入门 行业动态 更新时间:2024-10-11 17:24:55
本文介绍了调试性能问题的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在用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.

更新:您还可以使用 Debug.Write .然后,您需要加载 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.

更多推荐

调试性能问题的最佳方法是什么?

本文发布于:2023-11-07 10:26:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566207.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:性能   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!