我如何使用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
====================================
> 

我尝试: - (轮廓(阶乘100)),点击           - (配置文件阶乘)(阶乘100)点击 但它给了我同样的结果。 我在做什么错了?

有帮助吗?

解决方案

我不熟悉PLT方案profile模块,但也许你有实际调用该函数?

(profile (factorial 1000))

其他提示

您是否尝试过在(曲线(阶乘N)),直到有一个明显的停顿?起动N个

(阶乘100)是现代计算机应该能够在做种事<1毫秒。

只是走过场文档使我怀疑它只是阶乘的问题过快容易地天寒这种情况下。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top