I have a portable profiler: library (xitomatl profiler srfi-time). It
uses (srfi :19 time) and so it's limited by the resolution of
(srfi :19 time), which varies between different Scheme systems; on
Ikarus, it has a resolution of microseconds. (The library
(xitomatl profiler meta) could also be used if a source of times other
than (srfi :19 time) is available.)
It's made to be used by temporarily replacing define, lambda, and
case-lambda with its "/profiled" versions (which I think is the only way
it can be done as a portable library). E.g.:
> (library (use profiler)
(export
fib)
(import
(except (rnrs)
define lambda case-lambda)
(rename (xitomatl profiler srfi-time)
(define/profiled define)
(lambda/profiled lambda)
(case-lambda/profiled case-lambda)))
(define fib
(case-lambda
(() (values (fib 15) 'another))
((n) (if (<= n 1) 1 (+ (fib (- n 1)) (fib (- n 2))))))))
> (import (use profiler))
> (fib)
987
another
> (import (only (xitomatl profiler srfi-time) print-report))
> (print-report)
=================================================================
Profile for:
(case-lambda
(() (values (fib 15) 'another))
((n) (if (<= n 1) 1 (+ (fib (- n 1)) (fib (- n 2))))))
Statistics:
calls: 1974 returns: 1974 entries/exits: 1974
numbers of arguments to calls: 0 1
numbers of values returned: 1 2
average time: 0.00015906180344478217 sec
minimum time: 0.0 sec
maximum time: 0.030833 sec
=================================================================
>
It's kind of rough to use and still experimental, and I haven't looked
at it or used if for a while until just now, and I'm sure it could be
improved, and it might not be a good way to make a profiler. It was
interesting to make... Caveat emptor :) Try it out and let us know
what you think.
--
: Derick
----------------------------------------------------------------
On Thu, 2009-09-17 at 04:57 -0500, Eduardo Cavazos wrote:
> Hello,
>
> I've been having a grand old time with the 'time' macro, investigating
> the effects of subtle code changes. But for large programs, a profiler
> would be much better.
>
> Aziz, is there a profiler available for Ikarus? I'm more interested in
> finding out where my program is spending the majority of it's time, as
> opposed to "number of times a procedure is called". Even if you have an
> experimental one laying around, I'd be happy to try it.
>
> I've considered running my code in another Scheme for the profiler. For
> example, DrScheme has a profiler. Also, Larceny comes with an
> experimental profiler (lib/Debugger/profile.sch). One concern I have is
> that the results would be of limited use if the different systems use
> different compilation/optimization techniques. I.e. I really should run
> the profiler on Ikarus if that's the system I want my code to run fast on.
>
> One minor hurdle in the way of using the DrScheme profiler is that it
> requires an '#!r6rs' at the top of every file... Sure, I could add that
> but it seems silly when every other implementation I use doesn't demand it.
>
> Ed