开发者

Timing in Scheme

开发者 https://www.devze.com 2023-03-06 09:57 出处:网络
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.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消