Best Practice Instrumenting a Webpage when having parallel tasks
I try to get an understanding of the performance of a web page and use Trace.Write
Problem is that I use Parallel.Invoke and starts more threads where I would like to report back using Trace.Write
Parallel.Invoke(() => Chart1AndLegend(param),
() => Chart2(param),
() => Chart3(param),
() => Chart4(param));
I have realized that Trace.Write is not a g开发者_如何学Goood way of tracing as it is gives you the time since last entry which makes no sense if more threads are writing ..
Question: Any good suggestion how to instrument a page when using Parallel library or do I need to write my own tracing!?!?
Might be stating the obvious here, but what if you created a StopWatch (or a number of) and simply write the elapsed time in the Trace.Write message? I suppose the other thing would be identifying what thread/method you're in the trace category (use Thread.CurrentThread.ManagedThreadId).
Alternatively, you'll need to use something else like Enterprise Library, log4net or the tracing in System.Diagnostics (see http://www.15seconds.com/issue/020910.htm for a full discussion of tracing in System.Diagnostics).
精彩评论