Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the performance impact of tracing in C# and ASP.NET?

I found this in some production login code I was looking at recently...

HttpContext.Current.Trace.Write(query + ": " + username + ", " + password));

...where query is a short SQL query to grab matching users. Does this have any sort of performance impact? I assume its very small.

Also, what is the purpose of this exact type of trace, using the HTTP Context? Where does this data get traced to? Thanks in advance!

like image 541
John B Avatar asked Mar 24 '09 13:03

John B


1 Answers

Yes it will have a performance impact whenever the TRACE conditional compilation constant is defined during build. Doing anything has some type of impact :)

As to whether or not this has a significant impact on an application. It's highly unlikely that it would as Trace is designed to be run and is run in many production applications. Only an abuse of the feature should lead to a noticable performance difference.

But as always, don't trust me, trust the profiler.

like image 137
JaredPar Avatar answered Oct 25 '22 16:10

JaredPar