Question

I'm currently trying to do exercise 1.22, which needs a function called runtime that returns the number of milliseconds the system has been running. However, my environment (R5RS) does not seem to have this. It does not have time, current-milliseconds, current-inexact-milliseconds, etc, either.

What function do I have access to, to profile my function? Which functions returns the number of milliseconds, microseconds, etc, that have passed? I would of course prefer the highest precision timer available.

Was it helpful?

Solution

Probably, the best thing to do is switch the language in DrRacket to "Use the language declared in the source", and start your file with #lang racket. Then functions like current-seconds and friends will be available.

Alternatively, you could use the profiling library, available via (require profile) and documented here.

Finally, you might want to look at Neil Van Dyke's SICP library for DrRacket.

OTHER TIPS

I used current-inexact-milliseconds when I did that exercise. Spoiler Alert: You can see my solution on my blog at SICP Exercise 1.22: Timed Prime Test.

By the way, I only solved that problem after asking a similar question, Is there an equivalent to Lisp's “runtime” primitive in Scheme?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top