2007-06-13 03:14:14 -04:00
|
|
|
;;; FIB -- A classic benchmark, computes fib(35) inefficiently.
|
|
|
|
|
2007-11-04 12:03:32 -05:00
|
|
|
(library (rnrs-benchmarks fib)
|
2007-06-13 03:14:14 -04:00
|
|
|
(export main)
|
2007-11-04 12:03:32 -05:00
|
|
|
(import (rnrs) (rnrs-benchmarks))
|
2007-06-13 03:14:14 -04:00
|
|
|
|
|
|
|
(define (fib n)
|
|
|
|
(if (< n 2)
|
|
|
|
n
|
|
|
|
(+ (fib (- n 1))
|
|
|
|
(fib (- n 2)))))
|
|
|
|
|
|
|
|
(define (main . args)
|
|
|
|
(run-benchmark
|
|
|
|
"fib"
|
|
|
|
fib-iters
|
|
|
|
(lambda (result) (equal? result 9227465))
|
|
|
|
(lambda (n) (lambda () (fib n)))
|
|
|
|
35)))
|
|
|
|
|