追查.NET人的每一个例子删除默认
监听器:
Every example of tracing in .NET people remove the "Default
" listener:
<configuration>
<system.diagnostics>
<sources>
<source name="TraceSourceApp" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="ConsoleListener"/>
<add name="ETWListener"/>
<remove name="Default"/>
</listeners>
什么是默认监听器,为什么它有默认?
What is the Default listener, and why is it there by default?
有一个微软的家伙做了benchmarks不同听众的开销的:
A Microsoft guy did benchmarks of the overhead with different listeners:
Default |===============================14,196 ms=====/ /================>
TextWriterTraceListener |=========211 ms======>
EventProviderTraceListener |=> 77ms
什么是默认
跟踪监听器,为什么它这么慢?它是OutputDebugString?是OutputDebugString真正的两个数量级的比写入文件慢?
What is the Default
trace listener, and why is it so slow? Is it OutputDebugString
? Is OutputDebugString
really two orders of magnitude slower than writing to a file?
是有一个.NET TraceListener只是用OutputDebugString?
Is there a .NET TraceListener
that just uses OutputDebugString
?
什么是的默认的跟踪监听器,它为什么这么慢,为什么会习惯上删除,如果它是如此糟糕,为什么它是默认的?
What is the default trace listener, why is it so slow, why is it customarily removed, and if it's so bad why is it the default?
这是从博客文章如何code的运行并不清楚,但DefaultTraceListener被记录是这样的:
It's not clear from that blog post how the code was run, but the DefaultTraceListener
is documented like this:
默认情况下,Write和WriteLine方法放出消息,在Win32 OutputDebugString的功能,并给Debugger.Log方法。有关的OutputDebugString功能的信息,请参阅平台SDK或MSDN。
By default, the Write and WriteLine methods emit the message to the Win32 OutputDebugString function and to the Debugger.Log method. For information about the OutputDebugString function, see the Platform SDK or MSDN.
因此,如果 Debugger.Log
实际上是打印到UI窗口(而且很有可能它的滚动等),我可以看到,造成大量的经济放缓。
So if Debugger.Log
is actually printing to a UI window (and quite possibly scrolling it etc) I can see that causing a lot of the slowdown.