vile / bench / native / datum-read-write-200.scm
14 lines · 14 sloc · 700 bytes · 76646891b77a3d5c6af4a1e42b122cd61dc1654b
Raw
1(define datum-text "(1 2 (3 4) \"abc\" #(5 6))")
2(define (benchmark seed)
3 (let loop ((n (+ 200 seed)) (acc 0))
4 (if (= n 0) acc
5 (let* ((input (open-input-string datum-text)) (datum (read input)) (output (open-output-string)))
6 (write datum output)
7 (let ((text (get-output-string output)))
8 (close-input-port input) (close-output-port output)
9 (if (string=? text datum-text) (loop (- n 1) (+ acc (string-length text))) -1))))))
10(define (run-batch count)
11 (let loop ((left count) (seed 0))
12 (if (= left 0) 4800
13 (if (= (benchmark seed) (if (= seed 0) 4800 (if (= seed 1) 4824 (if (= seed 2) 4848 4872))))
14 (loop (- left 1) (if (= seed 3) 0 (+ seed 1))) #f))))
15