2009-07-01 18 views
2

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

我想: - (配置文件(階乘100))
- (輪廓階乘)(階乘100)
但它給了我同樣的結果。 我在做什麼錯?

回答

1

我不熟悉PLT Scheme中的profile模塊,但是也許您必須真正調用函數?

(profile (factorial 1000)) 
+0

我也試過,但它沒有工作:( – unj2 2009-07-01 02:59:43

1

您是否試過在(配置文件(因子N))中啓動N,直到出現明顯的暫停?

(因子100)是現代計算機應該能夠在< 1毫秒內完成的事情。

只是略讀documentation讓我懷疑它只是一個階乘問題太快而無法輕鬆描述的情況。