Debian Codegraph @

benchmarks.larceny/src/sum1.scm

raw
1 ;;; SUM1 -- One of the Kernighan and Van Wyk benchmarks.
2
3 (define inport #f)
4
5 (define (sumport port sum-so-far)
6 (let ((x (read port)))
7 (if (eof-object? x)
8 sum-so-far
9 (sumport port (FLOAT+ x sum-so-far)))))
10
11 (define (sum port)
12 (sumport port 0.0))
13
14 (define (go)
15 (set! inport (open-input-file "../../src/rn100"))
16 (let ((result (sum inport)))
17 (close-input-port inport)
18 result))
19
20 (define (main . args)
21 (run-benchmark
22 "sum1"
23 sum1-iters
24 (lambda (result) (and (FLOAT>= result 15794.974999999)
25 (FLOAT<= result 15794.975000001)))
26 (lambda () (lambda () (go)))))