SICP、Scheme、DrRacket 问题:定时器/分析器功能?
我目前正在尝试做练习1.22,它需要一个名为runtime 的函数,它返回系统已运行的毫秒数。然而我的环境(R5RS)似乎没有这个。它也没有时间、当前毫秒、当前不精确毫秒等。
我可以访问什么功能来分析我的功能?哪些函数返回已经过去的毫秒数、微秒数等?我当然更喜欢最高精度的计时器。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许,最好的办法是将 DrRacket 中的语言切换为“使用源代码中声明的语言”,并以
#langracket
开始您的文件。然后诸如current-seconds
之类的函数将可用。或者,您可以使用分析库,可通过
(require profile)
获取并记录 这里。最后,您可能需要查看 Neil Van Dyke 的 DrRacket 的 SICP 库。
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 likecurrent-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.
我用了 当前不精确毫秒 当我做那个练习时。 剧透警告:您可以在我的博客上查看我的解决方案:SICP 练习 1.22:定时 Prime 测试。
顺便说一句,我只是在问了类似的问题后才解决了这个问题, Scheme 中是否有相当于 Lisp 的“运行时”原语?
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?