[plt-scheme] profiling in MzScheme
At Wed, 16 Mar 2005 08:19:39 +0100, Johannes Brauer wrote:
> (define (flatten x)
> (cond
> [(null? x) '()]
> [(not (pair? (car x)))
> (cons (car x) (flatten (cdr x)))]
> [else
> (append (flatten (car x)) (flatten (cdr x)))]))
>
> by
>
> (flatten '((a b) c))
>
> generates the profile:
>
> % Time Msec Calls Function
> 100.000 0 6 flatten
The profiler uses a millisecond timer, and the expression shouldn't
take nearly a millisecond to execute, so the report is accurate within
a millisecond.
Actually, on many systems, the timer's resolution is worse than a
millisecond. On the machine I'm using now, I think it's 10 msec.
If you evaluate something like
(flatten (vector->list (make-vector 1000 '(1 2 3))))
do you get a non-zero time for `flatten'? (It's 20msec for me.)
Matthew