Debian Codegraph @

benchmarks.larceny/src/string.scm

raw
1 ;;; STRING -- One of the Kernighan and Van Wyk benchmarks.
2
3 (define s "abcdef")
4
5 (define (grow)
6 (set! s (string-append "123" s "456" s "789"))
7 (set! s (string-append
8 (substring s (quotient (string-length s) 2) (string-length s))
9 (substring s 0 (+ 1 (quotient (string-length s) 2)))))
10 s)
11
12 (define (trial n)
13 (do ((i 0 (+ i 1)))
14 ((> (string-length s) n) (string-length s))
15 (grow)))
16
17 (define (my-try n)
18 (do ((i 0 (+ i 1)))
19 ((>= i 10) (string-length s))
20 (set! s "abcdef")
21 (trial n)))
22
23 (define (main . args)
24 (run-benchmark
25 "string"
26 string-iters
27 (lambda (result) (equal? result 524278))
28 (lambda (n) (lambda () (my-try n)))
29 500000))