我如何在 DrScheme 中进行配置?
如何使用 DrScheme 分析我的函数?
(require profile)
(define (factorial n)
(cond
((= n 1) 1)
(else (* n (factorial (- n 1))))))
(profile factorial)
上面的代码返回
Profiling results
-----------------
Total cpu time observed: 0ms (out of 0ms)
Number of samples taken: 0 (once every 0ms)
====================================
Caller
Idx Total Self Name+srcLocal%
ms(pct) ms(pct) Callee
====================================
>
我尝试过的: - (profile (factorial 100))
-(轮廓阶乘)(阶乘 100)
但它给了我同样的结果。 我究竟做错了什么?
How Do I profile my functions using DrScheme?
(require profile)
(define (factorial n)
(cond
((= n 1) 1)
(else (* n (factorial (- n 1))))))
(profile factorial)
The above code returns
Profiling results
-----------------
Total cpu time observed: 0ms (out of 0ms)
Number of samples taken: 0 (once every 0ms)
====================================
Caller
Idx Total Self Name+srcLocal%
ms(pct) ms(pct) Callee
====================================
>
I tried: - (profile (factorial 100))
- (profile factorial) (factorial 100)
But it gives me the same result.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不熟悉 PLT 方案中的
profile
模块,但也许您必须实际调用该函数?I'm not familiar with the
profile
module in PLT Scheme, but perhaps you have to actually call the function?您是否尝试过在(轮廓(阶乘 N))中调高 N 直到出现明显的停顿?
(阶乘 100)是现代计算机应该能够在 <1 毫秒内完成的事情。
只是浏览文档让我怀疑这只是阶乘太快的问题轻松分析该案例。
Have you tried cranking up N in (profile (factorial N)) until there's a noticeable pause?
(factorial 100) is the kind of thing a modern computer should be able to do in <1ms.
Just skimming the documentation makes me suspect its just a matter of factorial being too fast to easily profile for that case.