Get stack trace quickly

delphi package - automated exception handling

Get stack trace quickly

Postby ExceptionHandling » Fri Aug 05, 2016 1:57 pm

I am searching for a more performant way to get the current stack trace. The tracing needs to be done in a central method deep in the code, which is necessary to determine specific code lines for restructuring.

So far I used the function MadExcept.CreateBugReport to return a stack trace, but this function takes up to 800 milliseconds per method call. Then I tried to use the function MadStackTrace.Stacktrace, which takes up to 40-45 milliseconds, but still takes too long.

Is there a way to get the current stack track more quickly? Maybe the stack trace can be shortened or something like that?
ExceptionHandling
 
Posts: 3
Joined: Fri Aug 05, 2016 1:29 pm

Re: Get stack trace quickly

Postby madshi » Fri Aug 05, 2016 2:10 pm

Do you always need the stack trace? Or do you just want to store it, and then maybe you will need it later? If you only need it sometimes, there's a way to store the necessary information for a stack trace very quickly, and then only do the actual processing in case you need it, at a later point in time.

If you always need it, you could set the StackTrace's "dumbTrace" parameter to true, which should bring a nice performance boost, on the cost of having more "noise" (invalid stack items) in the trace.
madshi
Site Admin
 
Posts: 9432
Joined: Sun Mar 21, 2004 5:25 pm

Re: Get stack trace quickly

Postby ExceptionHandling » Fri Aug 05, 2016 2:51 pm

I need to determine 2 stack traces, whereas the 1st trace is temporarily stored in a variable for later purpose. When specific conditions in the code apply, a 2nd stack trace is also determined, then both stack traces will be logged in a database.

I will try to use this dumb trace parameter.
ExceptionHandling
 
Posts: 3
Joined: Fri Aug 05, 2016 1:29 pm

Re: Get stack trace quickly

Postby ExceptionHandling » Fri Aug 05, 2016 3:11 pm

When setting the parameter to True the performance doesn't really seem to have improved. For testing I used the function MadStackTrace.StackTrace with default settings, but with the suggested parameter set to true. The stack trace determination still takes up to 40-45 milliseconds.
ExceptionHandling
 
Posts: 3
Joined: Fri Aug 05, 2016 1:29 pm

Re: Get stack trace quickly

Postby madshi » Fri Aug 05, 2016 3:31 pm

Are we talking about a 32bit or 64bit EXE? In 64bit I suppose performance might not benefit, but I expected there to be a difference at least in 32bit.

Anyway, I fear I don't really have a stack trace method which outputs a valid stack trace but is optimized for highest performance. I do have 2 variants: 1) Slow and good quality. Or 2) just store the information, and do the processing later. For madExcept's own purposes it's all that's needed. I don't really need a fast method which still outputs a "full" stack trace string, so I didn't really spend time on developing such a function.
madshi
Site Admin
 
Posts: 9432
Joined: Sun Mar 21, 2004 5:25 pm


Return to madExcept

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests

cron