rlbond - you've probably noticed already, but for anyone else in the future...
I've just been using the StackWalker
library and after some testing, I realised that if you're using it for anything other than displaying information on an application-stopping exception, it's worth creating a single instance of
the StackWalker
object. For a multithreaded application, you could create an instance per thread using TLS to avoid synchronisation issues (haven't tried this yet though - be warned).
The reason for this is that 99%+ of the time to generate a trace is spent loading in all of the symbols. This percentage will vary - the 99% is for my setup, where I subclass and override OnOutput()
to save everything into a buffer rather than displaying there and then but the point is the same - don't use them as a single-use object if you're going to use them a lot.
My timings were 42 ms to create an instance, get the stack trace and throw it away compared to around 0.6 ms to generate second and subsequent traces using the same object.
Just something to bear in mind.