开发者

System.Diagnostics.Trace Overhead

I have an application that uses Trace.WriteLine in nearly every method it uses. The program has several different problems.

What I am wondering is if there is any overhead that comes with using System.Diagnostics.Trace.WriteLine so often? I am looking to solve problems as I discover them and I personally feel using Debug/Trace WriteLine in nearly every single method within the program has to come with a p开发者_开发百科erformance cost.

The programmer who wrote this application was rushed and also included some asset statements that has caused trouble for us in the past.


It's possible that Trace could result in a performance problem for your application. Especially if it's used in every single method in the the program.

Luckily Trace.WriteLine has a Conditional attribute attached to it: Trace. If you compile the application without Trace defined it will compile as if the calls simply didn't exist. This will allow you to quickly do an eyeball test to see if it is affecting performance.

The only way to know though is to hook the application up to a profiler. This will tell you definitively if Trace.WriteLine is a problem for your application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜