benaadams / Ben.Demystifier

High performance understanding for stack traces (Make error logs more productive)
Apache License 2.0
2.75k stars 118 forks source link

Potential performance improvements #167

Open kemsky opened 3 years ago

kemsky commented 3 years ago

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);
        }
ghost commented 2 years ago

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