I'm currently going through the Project Euler's problems and I'm so开发者_运维问答lving 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?
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
精彩评论