degenerate let forms
[bpt/guile.git] / gc-benchmarks / string.scm
1 ;;; From from http://www.ccs.neu.edu/home/will/Twobit/KVW/string.txt .
2 ; string test
3 ; (try 100000)
4
5 (define s "abcdef")
6
7 (define (grow)
8 (set! s (string-append "123" s "456" s "789"))
9 (set! s (string-append
10 (substring s (quotient (string-length s) 2) (string-length s))
11 (substring s 0 (+ 1 (quotient (string-length s) 2)))))
12 s)
13
14 (define (trial n)
15 (do ((i 0 (+ i 1)))
16 ((> (string-length s) n) (string-length s))
17 (grow)))
18
19 (define (try n)
20 (do ((i 0 (+ i 1)))
21 ((>= i 10) (string-length s))
22 (set! s "abcdef")
23 (trial n)))
24
25 (try 50000000)