summaryrefslogtreecommitdiff
path: root/gc-benchmarks/string.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-01-12 23:34:42 +0100
committerAndy Wingo <wingo@pobox.com>2009-01-12 23:34:42 +0100
commitd5968e7f4e96d957157a31e577d8792afe655371 (patch)
tree7f18144704b07821d02f797601f00cfacaf360fd /gc-benchmarks/string.scm
parent616167fc12fd42c14e021b5496e91154b3a0e8c0 (diff)
parentbf4200ca9f1b288d2eddc344fd315f8a3d199661 (diff)
downloadguile-d5968e7f4e96d957157a31e577d8792afe655371.tar.gz
Merge branch 'master' into vm
Diffstat (limited to 'gc-benchmarks/string.scm')
-rw-r--r--gc-benchmarks/string.scm25
1 files changed, 25 insertions, 0 deletions
diff --git a/gc-benchmarks/string.scm b/gc-benchmarks/string.scm
new file mode 100644
index 000000000..727016352
--- /dev/null
+++ b/gc-benchmarks/string.scm
@@ -0,0 +1,25 @@
+;;; From from http://www.ccs.neu.edu/home/will/Twobit/KVW/string.txt .
+; string test
+; (try 100000)
+
+(define s "abcdef")
+
+(define (grow)
+ (set! s (string-append "123" s "456" s "789"))
+ (set! s (string-append
+ (substring s (quotient (string-length s) 2) (string-length s))
+ (substring s 0 (+ 1 (quotient (string-length s) 2)))))
+ s)
+
+(define (trial n)
+ (do ((i 0 (+ i 1)))
+ ((> (string-length s) n) (string-length s))
+ (grow)))
+
+(define (try n)
+ (do ((i 0 (+ i 1)))
+ ((>= i 10) (string-length s))
+ (set! s "abcdef")
+ (trial n)))
+
+(try 50000000) \ No newline at end of file