[plt-scheme] Benchmarks using R5RS only?

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Thu Jan 12 08:46:14 EST 2006

Gregory Woodhouse wrote:
> I was curious to see how fast Quicksort would be in PLT Scheme and  how 
> much difference compilation would make, so I wrote a little  program 
> (see below). It won't run under R5RS, though, because it uses  random 
> (which I can implement) and time (which I do not know how to  
> implement). How can I modify this code to run under R5RS only?

If you mean the R5RS-language in PLT Scheme you can use this trick:

     (#%require (only mzscheme random))

Otherwise just generate a large random list and put a

(define a-random-list (list 1 4 1 4 2 ...))

at the top of the file.


> ;;try-it
> (define try-it
>   (lambda (n)
>     (begin
>       (define output '())
>       (time (set! output (quick (random-list n 1000)))))))

If you use the time function, you should garbage collect first,
so the function you want to time doesn't get penalized by a previous
evaluation.

  (define try-it
    (lambda (n)
      (begin
        (define output '())
        (collect-garbage)
        (time (set! output (quick (random-list n 1000)))))))


BTW - were you comparing DrScheme times with MzScheme? If so,
remember that you under language details can get DrScheme to
run faster if you remove the debug information.

-- 
Jens Axel Søgaard





Posted on the users mailing list.