123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- (define-module (benchmarks write)
- #:use-module (benchmark-suite lib))
- (define %narrow-string
- (make-string 30 #\a))
- (define %wide-string
- (make-string 30 #\λ))
- (define %long-string
- (make-string 300 #\x))
- (define-syntax repeat
- (lambda (s)
- (syntax-case s ()
- ((_ 1 exp)
- #'exp)
- ((_ count exp)
- (with-syntax ((count (- (syntax->datum #'count) 1)))
- #'(begin
- exp
- (repeat count exp)))))))
- (with-benchmark-prefix "string-hash"
- (benchmark "narrow string" 100000
- (repeat 100 (string-hash %narrow-string)))
- (benchmark "wide string" 100000
- (repeat 100 (string-hash %wide-string)))
- (benchmark "long string" 100000
- (repeat 100 (string-hash %long-string))))
|