~ chicken-core (master) /tests/sgrep.scm
Trap1;;;; sgrep.scm - grepping benchmark234(import chicken.io chicken.irregex chicken.port)567(define big-string8 (with-input-from-file (optional (command-line-arguments) "compiler.scm") read-string))910(define-syntax bgrep11 (syntax-rules ()12 ((_ n expr)13 (time14 (do ((i n (fx- i 1)))15 ((eq? i 0))16 (with-input-from-string big-string17 (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))))))))2728(define-syntax rx129 (syntax-rules ()30 ((_) "\\((.*), (.*)\\)")))3132(define-syntax rx233 (syntax-rules ()34 ((_) '(: #\( (submatch (* any)) ", " (submatch (* any))))))3536(bgrep 1 (rx1))