This is the mail archive of the
mailing list for the Guile project.
Re: Scheme profiler?
Keisuke Nishida <firstname.lastname@example.org> writes:
> > (trap-enable 'apply-frame)
> > The same handler is called also if you do (debug-enable 'trace).
> > Look at the implementation of `trace' in (ice-9 debug) to see how to
> > use the handler.
> Yes, I noticed it and tried to reimplement a profiler by using it,
> but I realized that it might be hard. Since apply-frame-handler can
> be called several times for each procedure call if the procedure is
Hmm... but there is no difference from the patch you posted---it has
the same problem, or have I missed something?
> recording the time for such a procedure could be tricky.
I think what we have here is a problem very similar to that of
`trace'. The tracing algorithm also needs to know when the exit
corresponding to a particular exit happens. As Harvey points out in
his message, this is handled by using apply-frame-handler together
Please look at the implementation of trace in (ice-9 debug). It is
pretty straightforward code. And feel free to ask if there is
> BHW, there is another hook called enter-frame-handler. When is it
It's called at the start of the evaluation of every form, which in the
Guile evaluator is equivalent to the creation of a new stack frame.
At this point in time, you only have access to the source expression
and the environment, not the procedure. I don't think this hook is
useful for you here.
> When I tried using it, it was never called.
You need to enable it using