2007-06-13 10:49:54 -04:00
|
|
|
;;; SUMFP -- Compute sum of integers from 0 to 10000 using floating point
|
2007-11-04 12:03:32 -05:00
|
|
|
(library (rnrs-benchmarks sumfp)
|
2007-06-13 10:49:54 -04:00
|
|
|
(export main)
|
2007-11-04 12:03:32 -05:00
|
|
|
(import (rnrs) (rnrs arithmetic flonums) (rnrs-benchmarks))
|
2007-06-13 10:49:54 -04:00
|
|
|
|
|
|
|
|
|
|
|
(define (run n)
|
|
|
|
(let loop ((i n) (sum 0.))
|
|
|
|
(if (fl<? i 0.)
|
2007-06-15 01:59:49 -04:00
|
|
|
sum
|
|
|
|
(loop (fl- i 1.) (fl+ i sum)))))
|
2007-06-13 10:49:54 -04:00
|
|
|
|
|
|
|
(define (main . args)
|
|
|
|
(run-benchmark
|
|
|
|
"sumfp"
|
|
|
|
sumfp-iters
|
|
|
|
(lambda (result) (equal? result 50005000.))
|
|
|
|
(lambda (n) (lambda () (run n)))
|
|
|
|
10000.)))
|