1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- (define-module (benchmarks read)
- :use-module (benchmark-suite lib))
- (define %files-to-load
-
- (map %search-load-path
- '("ice-9/boot-9.scm" "ice-9/common-list.scm"
- "ice-9/format.scm" "ice-9/optargs.scm"
- "ice-9/session.scm" "ice-9/getopt-long.scm"
- "ice-9/psyntax-pp.scm")))
- (define (load-file-with-reader file-name reader buffering)
- (with-input-from-file file-name
- (lambda ()
- (apply setvbuf (current-input-port) buffering)
- (let loop ((sexp (reader)))
- (if (eof-object? sexp)
- #t
- (loop (reader)))))))
- (define (exercise-read buffering)
- (for-each (lambda (file)
- (load-file-with-reader file read buffering))
- %files-to-load))
- (define small "\"hello, world!\"")
- (define large (string-append "\"" (make-string 1234 #\A) "\""))
- (fluid-set! %default-port-encoding "UTF-8")
- (with-benchmark-prefix "read"
- (benchmark "'none" 5
- (exercise-read (list 'none)))
- (benchmark "'line" 10
- (exercise-read (list 'line)))
- (benchmark "'block 4096" 10
- (exercise-read (list 'block 4096)))
- (benchmark "'block 8192" 10
- (exercise-read (list 'block 8192)))
- (benchmark "'block 16384" 10
- (exercise-read (list 'block 16384)))
- (benchmark "small strings" 100000
- (call-with-input-string small read))
- (benchmark "large strings" 100000
- (call-with-input-string large read)))
|