Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timing in Scheme

I'm currently going through the Project Euler's problems and I'm solving them both in C# and Scheme (the Racket implementation). I know C# but I'm learning Scheme as I go along.

Now, on top of having the correct results for the problems, I like to come up with the fastest possible solution I can think of. To that effect, in C# I use StopWatch to measure the performance of my code. Is there a similar Scheme library / functionality to time code execution?

like image 289
joce Avatar asked May 17 '11 22:05

joce


1 Answers

Just enclose the whole part you want to time in the time expression (this works in most implementations, including Racket):

(time (rest-of-program))

You can also use the Unix command time if you're on Linux/OSX/BSD/etc., e.g.

time ./my_program
like image 134
Rafe Kettler Avatar answered Nov 11 '22 05:11

Rafe Kettler