[plt-scheme] Futures performance
When I run your code I see the correct results (changing the 30 to a
36 and adding "#lang scheme" to the top of the program and otherwise
running your program as is), namely:
cpu time: 527 real time: 538 gc time: 0
14930352
cpu time: 529 real time: 351 gc time: 0
14930352
When I run within drscheme with debugging enabled and using 32 as the
parameter, I'm getting the right thing too:
cpu time: 830 real time: 852 gc time: 0
2178309
cpu time: 775 real time: 530 gc time: 0
2178309
Robby
On Tue, May 25, 2010 at 9:53 PM, Groshev Dmitry <a2alt at yandex.ru> wrote:
> What am I doing wrong? Here is the code and some tests:
>
> (require scheme/future)
>
> (define (fib n)
> (case n
> [(0) 0]
> [(1) 1]
> [else (let ((a (fib (- n 1)))
> (b (fib (- n 2))))
> (+ a b))]))
>
> (define (fibp n)
> (case n
> [(0) 0]
> [(1) 1]
> [else (let ((a (future (lambda () (fib (- n 1)))))
> (b (future (lambda () (fib (- n 2))))))
> (+ (touch a) (touch b)))]))
>
>> (time (fib 30))
> cpu time: 546 real time: 539 gc time: 0
> 832040
>> (time (fibp 30))
> cpu time: 8986 real time: 7814 gc time: 391
> 832040
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>