[plt-scheme] profiling in MzScheme

From: Johannes Brauer (brauer at nordakademie.de)
Date: Thu Mar 17 04:21:28 EST 2005

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> 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
>
Yes, I do (50msec for me)! Thank you for the hints.

Johannes



Posted on the users mailing list.