[racket] Extract values from `time` function

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Sun Feb 5 10:42:30 EST 2012

You want to use the `time-apply' function.  The documentation is here:
http://docs.racket-lang.org/reference/time.html?q=time-apply#%28def._%28%28quote._~23~25kernel%29._time-apply%29%29

In general, (time e) can be converted to (time-apply (lambda () e)
'()), which produces values instead of printing them.

On Sun, Feb 5, 2012 at 10:27 AM, Sergi Mansilla
<sergi.mansilla at gmail.com> wrote:
> Hi,
>
> For benchmarking purposes, I am running a function hundreds of times
> and want to make an average of the time it spends running. For that
> purpose I am now using `current-inexact-milliseconds` before and after
> he loop, and then subtracting both times and dividing by the
> iterations performed.
>
> I'd like to do that with the `time` function, but I can't figure out
> how to extract the values it prints, since it doesn't seem to be a
> return value. I am clearly missing something obvious. How can I use
> values returned by `time`?
>
> Thanks a lot,
>
> Sergi
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.