Ben.Demystifier icon indicating copy to clipboard operation
Ben.Demystifier copied to clipboard

Potential performance improvements

Open kemsky opened this issue 3 years ago • 1 comments

Enhanced classes still do call parent default constructor e.g.:

image

CaptureStackTrace call is redundant, it comes from StackTrace() constructor.

In this case, we could explicitly call StackTrace(StackFrame frame) with some dummy value, to avoid an expensive call:

        public EnhancedStackTrace(Exception e) : base((StackFrame) null)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            _frames = GetFrames(e);
        }


        public EnhancedStackTrace(StackTrace stackTrace) : base((StackFrame) null)
        {
            if (stackTrace == null)
            {
                throw new ArgumentNullException(nameof(stackTrace));
            }

            _frames = GetFrames(stackTrace);
        }

kemsky avatar Jul 11 '21 13:07 kemsky

I also wonder if the same could be done for EnhancedStackFrame: image I'm having a lot of performance penalties due to this :(

Ararem avatar Oct 27 '21 05:10 Ararem