1;;;; sgrep.scm - grepping benchmark 2 3 4(import chicken.io chicken.irregex chicken.port) 5 6 7(define big-string 8 (with-input-from-file (optional (command-line-arguments) "compiler.scm") read-string)) 9 10(define-syntax bgrep 11 (syntax-rules () 12 ((_ n expr) 13 (time 14 (do ((i n (fx- i 1))) 15 ((eq? i 0)) 16 (with-input-from-string big-string 17 (lambda () 18 (let ((h 0) 19 (c 0)) 20 (do ((line (read-line) (read-line))) 21 ((eof-object? line)) 22 (set! c (fx+ c 1)) 23 ;(when (zero? (fxmod c 500)) (print* ".")) 24 (when (irregex-search expr line) 25 (set! h (fx+ h 1)))) 26 h)))))))) 27 28(define-syntax rx1 29 (syntax-rules () 30 ((_) "\\((.*), (.*)\\)"))) 31 32(define-syntax rx2 33 (syntax-rules () 34 ((_) '(: #\( (submatch (* any)) ", " (submatch (* any)))))) 35 36(bgrep 1 (rx1)) 37