[plt-scheme] profiling in MzScheme

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Mar 16 07:38:08 EST 2005

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



Posted on the users mailing list.