本文介绍了是否有与Lisp的“运行时"相当的功能? Scheme中的原始数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 SICP第1.2节.6 ,练习1.22:

我正在使用 DrScheme ,在该环境下似乎无法使用运行时,所以我正在寻找一个好的替代品.我在PLT计划参考中发现,有一个当前毫秒原语.有人知道Scheme中是否有一个分辨率更高的计时器?

I'm using DrScheme, where runtime doesn't seem to be available, so I'm looking for a good substitute. I found in the PLT-Scheme Reference that there is a current-milliseconds primitive. Does anyone know if there's a timer in Scheme with better resolution?

推荐答案

current-milliseconds 是一个从系统返回当前毫秒计数的函数,但它可能会减少. current-inexact-milliseconds 类似,但是返回保证增加的浮点数.

current-milliseconds is a function that returns the current millisecond count from the system, but it might decrease. current-inexact-milliseconds is similar, but returns a guaranteed-to-increase floating point number.

在该页面上也可以找到很多类似的功能,但是如果您只需要计时某个功能,则只需使用( time expr ),它将打印出计算表达式所需的时间.

There are also a bunch of similar functions that you can find on that page, but if all you need is to time a certain function, then just use (time expr) and it will print out the time it took to evaluate the expression.

这里另一件事是 profiler ,以防您需要更多详细信息分析您的代码.

Another thing that is relevant here is the profiler, in case you need some more verbose analysis of your code.

这篇关于是否有与Lisp的“运行时"相当的功能? Scheme中的原始数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 10:11