trying to get pcre to work

svn: r4321
This commit is contained in:
Matthew Flatt 2006-09-13 10:07:01 +00:00
parent 72be8659b0
commit ce0ad68956
3 changed files with 286 additions and 150 deletions

View File

@ -1,86 +1,255 @@
#!/bin/sh
#|
exec mzscheme -qu "$0" ${1+"$@"}
|#
(module mz mzscheme
(define (test input rx iterations)
(printf "Testing ~s on ~a iterations of a ~a-byte input\n" rx
iterations
(bytes-length input))
(time
(let loop ([n iterations])
(unless (zero? n)
(regexp-match-positions rx input)
(loop (sub1 n))))))
(module auto mzscheme
(require (lib "process.ss")
(lib "port.ss")
(lib "list.ss")
(lib "date.ss")
(lib "cmdline.ss"))
(define (test-mzscheme input rx iterations)
(let ([rx (byte-pregexp rx)])
(let ([start (current-inexact-milliseconds)])
(let loop ([n iterations])
(unless (zero? n)
(regexp-match-positions rx input)
(loop (sub1 n))))
(- (current-inexact-milliseconds) start))))
(define (test-perl input rx iterations)
(with-output-to-file "test.pl"
(lambda ()
(with-input-from-file "perl_prefix.pl"
(lambda ()
(copy-port (current-input-port)
(current-output-port))))
(printf "test \"~a\", /~a/, \"/~a/\", ~a;\n"
input rx rx iterations))
'truncate)
(let ([s (open-output-bytes)])
(parameterize ([current-output-port s])
(system "perl test.pl"))
(parameterize ([current-input-port (open-input-string (get-output-string s))])
(read-line)
(* 1000 (read)))))
(define (test-pcre input rx iterations)
(let ([s (open-output-bytes)])
(parameterize (; [current-output-port s]
[current-input-port (open-input-bytes
(bytes-append
(string->bytes/latin-1 (format "/~a/S\n" rx))
input
#"\n"))])
(system (format "pcretest -t -Q -n ~a" iterations)))
(let ([m (regexp-match #rx"Execute time ([0-9.]*)" (get-output-string s))])
(if m
(* (string->number (cadr m)) iterations)
(begin
(printf "~a\n" (get-output-string s))
#f)))))
(define (random-letters n)
(let loop ([n n][accum null])
(if (zero? n)
(list->bytes accum)
(loop (sub1 n) (cons (+ (char->integer #\a)
(random 26))
accum)))))
(parameterize ([current-pseudo-random-generator (make-pseudo-random-generator)])
(random-seed 43)
(let loop ([n n][accum null])
(if (zero? n)
(list->bytes accum)
(loop (sub1 n) (cons (+ (char->integer #\a)
(random 26))
accum))))))
(test (make-bytes 100 (char->integer #\x)) #px#"(?s:.*)" 100000)
(test (make-bytes 1000 (char->integer #\x)) #px#"(?s:.*)" 100000)
(test (make-bytes 10000 (char->integer #\x)) #px#"(?s:.*)" 10000)
(test (make-bytes 100000 (char->integer #\x)) #px#"(?s:.*)" 1000)
(test (make-bytes 100 (char->integer #\x)) #px#".*" 100000)
(test (make-bytes 1000 (char->integer #\x)) #px#".*" 100000)
(test (make-bytes 10000 (char->integer #\x)) #px#".*" 100000)
(test (make-bytes 100000 (char->integer #\x)) #px#".*" 10000)
(test (make-bytes 100 (char->integer #\x)) #px#"(?s:(.)*)" 100000)
(test (make-bytes 1000 (char->integer #\x)) #px#"(?s:(.)*)" 100000)
(test (make-bytes 10000 (char->integer #\x)) #px#"(?s:(.)*)" 10000)
(test (make-bytes 100000 (char->integer #\x)) #px#"(?s:(.)*)" 1000)
(test (make-bytes 100 (char->integer #\x)) #px#"x*" 100000)
(test (make-bytes 1000 (char->integer #\x)) #px#"x*" 100000)
(test (make-bytes 10000 (char->integer #\x)) #px#"x*" 10000)
(test (make-bytes 100000 (char->integer #\x)) #px#"x*" 1000)
(test (make-bytes 100 (char->integer #\x)) #px#"[xy]*" 100000)
(test (make-bytes 1000 (char->integer #\x)) #px#"[xy]*" 10000)
(test (make-bytes 10000 (char->integer #\x)) #px#"[xy]*" 1000)
(test (make-bytes 100000 (char->integer #\x)) #px#"[xy]*" 100)
(test (make-bytes 100 (char->integer #\x)) #px#"(.)*" 100000)
(test (make-bytes 1000 (char->integer #\x)) #px#"(.)*" 100000)
(test (make-bytes 10000 (char->integer #\x)) #px#"(.)*" 100000)
(test (make-bytes 100000 (char->integer #\x)) #px#"(.)*" 10000)
(test (make-bytes 100 (char->integer #\x)) #px#"(x)*" 100000)
(test (make-bytes 1000 (char->integer #\x)) #px#"(x)*" 100000)
(test (make-bytes 10000 (char->integer #\x)) #px#"(x)*" 10000)
(test (make-bytes 100000 (char->integer #\x)) #px#"(x)*" 1000)
(test (make-bytes 100 (char->integer #\x)) #px#"(y|x)*" 10000)
(test (make-bytes 1000 (char->integer #\x)) #px#"(y|x)*" 1000)
(test (make-bytes 10000 (char->integer #\x)) #px#"(y|x)*" 100)
(test (make-bytes 100000 (char->integer #\x)) #px#"(y|x)*" 10)
(test (make-bytes 100 (char->integer #\x)) #px#"([yz]|x)*" 10000)
(test (make-bytes 1000 (char->integer #\x)) #px#"([yz]|x)*" 1000)
(test (make-bytes 10000 (char->integer #\x)) #px#"([yz]|x)*" 100)
(test (make-bytes 100000 (char->integer #\x)) #px#"([yz]|x)*" 10)
(test (make-bytes 100 (char->integer #\x)) #px#"([xy])*" 100000)
(test (make-bytes 1000 (char->integer #\x)) #px#"([xy])*" 10000)
(test (make-bytes 10000 (char->integer #\x)) #px#"([xy])*" 1000)
(test (make-bytes 100000 (char->integer #\x)) #px#"([xy])*" 100)
; (test (make-bytes 100 (char->integer #\x)) #px#"((x){2})*" 10000)
; (test (make-bytes 1000 (char->integer #\x)) #px#"((x){2})*" 10000)
; (test (make-bytes 10000 (char->integer #\x)) #px#"((x){2})*" 1000)
; (test (make-bytes 100000 (char->integer #\x)) #px#"((x){2})*" 100000)
(test (bytes-append (random-letters 100) #"FOOBARBAZ") #px#"[a-z]*FOOBARBAZ" 100000)
(test (bytes-append (random-letters 1000) #"FOOBARBAZ") #px#"[a-z]*FOOBARBAZ" 10000)
(test (bytes-append (random-letters 10000) #"FOOBARBAZ") #px#"[a-z]*FOOBARBAZ" 1000)
(test (bytes-append (random-letters 100) #"NOPE") #px#"[a-z]*FOOBARBAZ" 1000000)
(test (bytes-append (random-letters 1000) #"NOPE") #px#"[a-z]*FOOBARBAZ" 100000)
(test (bytes-append (random-letters 10000) #"NOPE") #px#"[a-z]*FOOBARBAZ" 10000)
(test (bytes-append (random-letters 100) #"FOOBARBAZ") #px#"([a-z])*FOOBARBAZ" 100000)
(test (bytes-append (random-letters 1000) #"FOOBARBAZ") #px#"([a-z])*FOOBARBAZ" 10000)
(test (bytes-append (random-letters 10000) #"FOOBARBAZ") #px#"([a-z])*FOOBARBAZ" 1000)
(test (bytes-append (random-letters 100) #"NOPE") #px#"([a-z])*FOOBARBAZ" 1000000)
(test (bytes-append (random-letters 1000) #"NOPE") #px#"([a-z])*FOOBARBAZ" 100000)
(test (bytes-append (random-letters 10000) #"NOPE") #px#"([a-z])*FOOBARBAZ" 10000)
(test (bytes-append (random-letters 100) #"FOOBARBAZ") #px#"([a-z]|ab)*FOOBARBAZ" 10000)
(test (bytes-append (random-letters 1000) #"FOOBARBAZ") #px#"([a-z]|ab)*FOOBARBAZ" 1000)
(test (bytes-append (random-letters 10000) #"FOOBARBAZ") #px#"([a-z]|ab)*FOOBARBAZ" 10)
(test (bytes-append (random-letters 100) #"NOPE") #px#"([a-z]|ab)*FOOBARBAZ" 1000000)
(test (bytes-append (random-letters 1000) #"NOPE") #px#"([a-z]|ab)*FOOBARBAZ" 100000)
(test (bytes-append (random-letters 10000) #"NOPE") #px#"([a-z]|ab)*FOOBARBAZ" 10000)
(test (bytes-append (random-letters 100) #"NOPE") #px#"(?i:[a-z]*FOOBARBAZ)" 1000)
(test (bytes-append (random-letters 1000) #"NOPE") #px#"(?i:[a-z]*FOOBARBAZ)" 10)
(test (bytes-append (random-letters 10000) #"NOPE") #px#"(?i:[a-z]*FOOBARBAZ)" 10)
)
(define (add-index l)
(let loop ([i 1][l l])
(if (null? l)
l
(cons (cons (let ([n (format "0~a" i)])
(substring n (- (string-length n) 2)))
(car l))
(loop (add1 i) (cdr l))))))
(define inputs
(add-index
(list
(list (make-bytes 100 (char->integer #\x)) #"(?s:.*)" 100000)
(list (make-bytes 1000 (char->integer #\x)) #"(?s:.*)" 100000)
(list (make-bytes 10000 (char->integer #\x)) #"(?s:.*)" 100000)
(list (make-bytes 100000 (char->integer #\x)) #"(?s:.*)" 100000)
(list (make-bytes 100 (char->integer #\x)) #"(?m:.*)" 100000)
(list (make-bytes 1000 (char->integer #\x)) #"(?m:.*)" 100000)
(list (make-bytes 10000 (char->integer #\x)) #"(?m:.*)" 100000)
(list (make-bytes 100000 (char->integer #\x)) #"(?m:.*)" 10000)
(list (make-bytes 100 (char->integer #\x)) #"(?s:(.)*)" 100000)
(list (make-bytes 1000 (char->integer #\x)) #"(?s:(.)*)" 100000)
(list (make-bytes 10000 (char->integer #\x)) #"(?s:(.)*)" 10000)
(list (make-bytes 100000 (char->integer #\x)) #"(?s:(.)*)" 1000)
(list (make-bytes 100 (char->integer #\x)) #"x*" 100000)
(list (make-bytes 1000 (char->integer #\x)) #"x*" 100000)
(list (make-bytes 10000 (char->integer #\x)) #"x*" 10000)
(list (make-bytes 100000 (char->integer #\x)) #"x*" 1000)
(list (make-bytes 100 (char->integer #\x)) #"[xy]*" 100000)
(list (make-bytes 1000 (char->integer #\x)) #"[xy]*" 10000)
(list (make-bytes 10000 (char->integer #\x)) #"[xy]*" 1000)
(list (make-bytes 100000 (char->integer #\x)) #"[xy]*" 100)
(list (make-bytes 100 (char->integer #\x)) #"(?m:(.)*)" 100000)
(list (make-bytes 1000 (char->integer #\x)) #"(?m:(.)*)" 100000)
(list (make-bytes 10000 (char->integer #\x)) #"(?m:(.)*)" 100000)
(list (make-bytes 100000 (char->integer #\x)) #"(?m:(.)*)" 10000)
(list (make-bytes 100 (char->integer #\x)) #"(x)*" 100000)
(list (make-bytes 1000 (char->integer #\x)) #"(x)*" 100000)
(list (make-bytes 10000 (char->integer #\x)) #"(x)*" 10000)
(list (make-bytes 100000 (char->integer #\x)) #"(x)*" 1000)
(list (make-bytes 100 (char->integer #\x)) #"(y|x)*" 10000)
(list (make-bytes 1000 (char->integer #\x)) #"(y|x)*" 1000)
(list (make-bytes 10000 (char->integer #\x)) #"(y|x)*" 100)
(list (make-bytes 100000 (char->integer #\x)) #"(y|x)*" 10)
(list (make-bytes 100 (char->integer #\x)) #"([yz]|x)*" 10000)
(list (make-bytes 1000 (char->integer #\x)) #"([yz]|x)*" 1000)
(list (make-bytes 10000 (char->integer #\x)) #"([yz]|x)*" 100)
(list (make-bytes 100000 (char->integer #\x)) #"([yz]|x)*" 10)
(list (make-bytes 100 (char->integer #\x)) #"([xy])*" 100000)
(list (make-bytes 1000 (char->integer #\x)) #"([xy])*" 10000)
(list (make-bytes 10000 (char->integer #\x)) #"([xy])*" 1000)
(list (make-bytes 100000 (char->integer #\x)) #"([xy])*" 100)
(list (make-bytes 100 (char->integer #\x)) #"((x){2})*" 10000)
(list (make-bytes 1000 (char->integer #\x)) #"((x){2})*" 10000)
(list (make-bytes 10000 (char->integer #\x)) #"((x){2})*" 100)
(list (make-bytes 100000 (char->integer #\x)) #"((x){2})*" 100)
(list (bytes-append (random-letters 100) #"FOOBARBAZ") #"[a-z]*FOOBARBAZ" 100000)
(list (bytes-append (random-letters 1000) #"FOOBARBAZ") #"[a-z]*FOOBARBAZ" 10000)
(list (bytes-append (random-letters 10000) #"FOOBARBAZ") #"[a-z]*FOOBARBAZ" 1000)
(list (bytes-append (random-letters 100) #"NOPE") #"[a-z]*FOOBARBAZ" 1000000)
(list (bytes-append (random-letters 1000) #"NOPE") #"[a-z]*FOOBARBAZ" 100000)
(list (bytes-append (random-letters 10000) #"NOPE") #"[a-z]*FOOBARBAZ" 10000)
(list (bytes-append (random-letters 100) #"FOOBARBAZ") #"([a-z])*FOOBARBAZ" 100000)
(list (bytes-append (random-letters 1000) #"FOOBARBAZ") #"([a-z])*FOOBARBAZ" 10000)
(list (bytes-append (random-letters 10000) #"FOOBARBAZ") #"([a-z])*FOOBARBAZ" 1000)
(list (bytes-append (random-letters 100) #"NOPE") #"([a-z])*FOOBARBAZ" 1000000)
(list (bytes-append (random-letters 1000) #"NOPE") #"([a-z])*FOOBARBAZ" 100000)
(list (bytes-append (random-letters 10000) #"NOPE") #"([a-z])*FOOBARBAZ" 10000)
(list (bytes-append (random-letters 100) #"FOOBARBAZ") #"([a-z]|ab)*FOOBARBAZ" 10000)
(list (bytes-append (random-letters 1000) #"FOOBARBAZ") #"([a-z]|ab)*FOOBARBAZ" 1000)
(list (bytes-append (random-letters 10000) #"FOOBARBAZ") #"([a-z]|ab)*FOOBARBAZ" 10)
(list (bytes-append (random-letters 100) #"NOPE") #"([a-z]|ab)*FOOBARBAZ" 1000000)
(list (bytes-append (random-letters 1000) #"NOPE") #"([a-z]|ab)*FOOBARBAZ" 100000)
(list (bytes-append (random-letters 10000) #"NOPE") #"([a-z]|ab)*FOOBARBAZ" 10000)
(list (bytes-append (random-letters 100) #"NOPE") #"(?i:[a-z]*FOOBARBAZ)" 1000)
(list (bytes-append (random-letters 1000) #"NOPE") #"(?i:[a-z]*FOOBARBAZ)" 10)
(list (bytes-append (random-letters 10000) #"NOPE") #"(?i:[a-z]*FOOBARBAZ)" 10))))
(define benchmark-names (map (lambda (t)
(string->symbol (car t)))
inputs))
(define testers
(list (list 'mzscheme test-mzscheme)
(list 'perl test-perl)
(list 'pcre test-pcre)))
(define impls (map car testers))
(define no-benchmarks (map (lambda (s)
(cons (string->symbol (format "no-~a" s))
s))
benchmark-names))
(define no-implementations (map (lambda (s)
(cons (string->symbol (format "no-~a" s))
s))
impls))
(define run-benchmarks #f)
(define run-implementations #f)
(define default-benchmarks benchmark-names)
(define default-implementations impls)
(define current-output-file (make-parameter #f))
;; Extract command-line arguments --------------------
(define args
(command-line
"auto"
(current-command-line-arguments)
(once-each
[("--show") "show implementations and benchmarks"
(printf "Implementations:\n")
(for-each (lambda (impl)
(printf " ~a\n" impl))
default-implementations)
(printf "Benchmarks: 1 - ~a\n"
(length inputs))]
[("-o" "--out") filename "append output to <filename>"
(current-output-file filename)])
(args impl-or-benchmark impl-or-benchmark)))
;; Process arguments ------------------------------
(for-each (lambda (arg)
(let ([s (string->symbol arg)])
(cond
[(memq s impls)
(set! run-implementations
(append (or run-implementations null)
(list s)))]
[(assq s no-implementations)
=> (lambda (a)
(set! run-implementations
(remq (cdr a)
(or run-implementations default-implementations))))]
[(memq s benchmark-names)
(set! run-benchmarks
(append (or run-benchmarks null)
(list s)))]
[(assq s no-benchmarks)
=> (lambda (a)
(set! run-benchmarks
(remq (cdr a)
(or run-benchmarks default-benchmarks))))]
[else
(error 'auto "mysterious argument: ~a" arg)])))
args)
(define actual-benchmarks-to-run
(or run-benchmarks
default-benchmarks))
(define actual-implementations-to-run
(or run-implementations
default-implementations))
;; Run benchmarks -------------------------------
(define (rprintf . args)
(apply printf args)
(when (current-output-file)
(with-output-to-file (current-output-file)
(lambda ()
(apply printf args))
'append)))
(define (run who which)
(let ([t (assoc (symbol->string which) inputs)])
(let-values ([(index input rx iterations) (apply values t)])
#;
(printf "Testing ~a: ~s on ~a iterations of a ~a-byte input\n"
who
rx
iterations
(bytes-length input))
(let ([ms ((cadr (assoc who testers)) input rx iterations)])
(rprintf "[~a ~s (~a #f #f) #f]\n"
who
(string->symbol (format "~a.~a/~a/~a" index rx (bytes-length input) iterations))
(and ms (inexact->exact (round ms))))))))
(rprintf "; ~a\n" (date->string (seconds->date (current-seconds)) #t))
(for-each (lambda (i)
(for-each (lambda (bm)
(run i bm))
actual-benchmarks-to-run))
actual-implementations-to-run))

View File

@ -0,0 +1,35 @@
(module pcre mzscheme
(require (lib "foreign.ss"))
(unsafe!)
(define pcre-lib (ffi-lib "libpcre"))
(define pcre-compile
(get-ffi-obj "pcre_compile" pcre-lib
(_fun _bytes _int _pointer _pointer _pointer
-> _pointer)))
(define pcre-study
(get-ffi-obj "pcre_study" pcre-lib
(_fun _pointer _int _pointer
-> _pointer)))
(define pcre-exec
(get-ffi-obj "pcre_exec" pcre-lib
(_fun _pointer _pointer _bytes _int
_int _int _bytes _int
-> _int)))
(define (pcregexp s)
(let* ([pat (pcre-compile s 0 #f #f #f)]
[extra #f #;(pcre-study pat 0 #f)])
(cons pat extra)))
(define random-vector (make-bytes 100))
(define (pcregexp-match re bytes)
(pcre-exec (car re) (cdr re) bytes (bytes-length bytes)
0 0 random-vector 10))
(display (pcregexp-match (pcregexp #".*") #"abc")))

View File

@ -13,71 +13,3 @@ sub test ($$$$) {
print (time - $start);
print "\n";
}
test "@{['x' x 100]}", /(.)*/s, "/(.)*/s", 100000;
test "@{['x' x 1000]}", /(.)*/s, "/(.)*/s",100000;
test "@{['x' x 10000]}", /(.)*/s, "/(.)*/s",100000;
test "@{['x' x 100000]}", /(.)*/s, "/(.)*/s",10000;
test "@{['x' x 100]}", /.*/m, "/.*/m", 100000;
test "@{['x' x 1000]}", /.*/m, "/.*/m", 100000;
test "@{['x' x 10000]}", /.*/m, "/.*/m", 10000;
test "@{['x' x 100000]}", /.*/m, "/.*/m", 1000;
test "@{['x' x 100]}", /.*/s, "/.*/s",100000;
test "@{['x' x 1000]}", /.*/s, "/.*/s",100000;
test "@{['x' x 10000]}", /.*/s, "/.*/s",100000;
test "@{['x' x 100000]}", /.*/s, "/.*/s",10000;
test "@{['x' x 100]}", /x*/, "/x*/", 100000;
test "@{['x' x 1000]}", /x*/, "/x*/", 100000;
test "@{['x' x 10000]}", /x*/, "/x*/", 10000;
test "@{['x' x 100000]}", /x*/, "/x*/", 1000;
test "@{['x' x 100]}", /[xy]*/, "/[xy]*/", 100000;
test "@{['x' x 1000]}", /[xy]*/, "/[xy]*/", 10000;
test "@{['x' x 10000]}", /[xy]*/, "/[xy]*/", 1000;
test "@{['x' x 100000]}", /[xy]*/, "/[xy]*/", 100;
test "@{['x' x 100]}", /(.)*/m, "/(.)*/", 100000;
test "@{['x' x 1000]}", /(.)*/m, "/(.)*/", 100000;
test "@{['x' x 10000]}", /(.)*/m, "/(.)*/", 10000;
test "@{['x' x 100000]}", /(.)*/m, "/(.)*/", 1000;
test "@{['x' x 100]}", /(x)*/, "/(x)*/", 100000;
test "@{['x' x 1000]}", /(x)*/, "/(x)*/", 100000;
test "@{['x' x 10000]}", /(x)*/, "/(x)*/", 10000;
test "@{['x' x 100000]}", /(x)*/, "/(x)*/", 1000;
test "@{['x' x 100]}", /(y|x)*/, "/(y|x)*/", 10000;
test "@{['x' x 1000]}", /(y|x)*/, "/(y|x)*/", 1000;
test "@{['x' x 10000]}", /(y|x)*/, "/(y|x)*/", 100;
test "@{['x' x 100000]}", /(y|x)*/, "/(y|x)*/", 10;
test "@{['x' x 100]}", /([yz]|x)*/, "/([yz]|x)*/", 10000;
test "@{['x' x 1000]}", /([yz]|x)*/, "/([yz]|x)*/", 1000;
test "@{['x' x 10000]}", /([yz]|x)*/, "/([yz]|x)*/", 100;
test "@{['x' x 100000]}", /([yz]|x)*/, "/([yz]|x)*/", 10;
test "@{['x' x 100]}", /([xy])*/, "/([xy])*/", 100000;
test "@{['x' x 1000]}", /([xy])*/, "/([xy])*/", 10000;
test "@{['x' x 10000]}", /([xy])*/, "/([xy])*/", 1000;
test "@{['x' x 100000]}", /([xy])*/, "/([xy])*/", 100;
#test "@{['x' x 100]}", /((x){2})*/, "/((x){2})*/", 10000;
#test "@{['x' x 1000]}", /((x){2})*/, "/((x){2})*/", 10000;
#test "@{['x' x 10000]}", /((x){2})*/, "/((x){2})*/", 1000;
#test "@{['x' x 100000]}", /((x){2})*/, "/((x){2})*/", 100000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..100)]}FOOBARBAZ", /[a-z]*FOOBARBAZ/, "/[a-z]*FOOBARBAZ/", 100000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..1000)]}FOOBARBAZ", /[a-z]*FOOBARBAZ/, "/[a-z]*FOOBARBAZ/", 10000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..10000)]}FOOBARBAZ", /[a-z]*FOOBARBAZ/, "/[a-z]*FOOBARBAZ/", 1000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..100)]}NOPE", /[a-z]*FOOBARBAZ/, "/[a-z]*FOOBARBAZ/", 1000000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..1000)]}NOPE", /[a-z]*FOOBARBAZ/, "/[a-z]*FOOBARBAZ/", 100000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..10000)]}NOPE", /[a-z]*FOOBARBAZ/, "/[a-z]*FOOBARBAZ/", 10000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..100)]}FOOBARBAZ", /([a-z])*FOOBARBAZ/, "/([a-z])*FOOBARBAZ/", 100000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..1000)]}FOOBARBAZ", /([a-z])*FOOBARBAZ/, "/([a-z])*FOOBARBAZ/", 10000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..10000)]}FOOBARBAZ", /([a-z])*FOOBARBAZ/, "/([a-z])*FOOBARBAZ/", 1000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..100)]}NOPE", /([a-z])*FOOBARBAZ/, "/([a-z])*FOOBARBAZ/", 1000000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..1000)]}NOPE", /([a-z])*FOOBARBAZ/, "/([a-z])*FOOBARBAZ/", 100000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..10000)]}NOPE", /([a-z])*FOOBARBAZ/, "/([a-z])*FOOBARBAZ/", 10000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..100)]}FOOBARBAZ", /([a-z]|ab)*FOOBARBAZ/, "/([a-z]|ab)*FOOBARBAZ/", 10000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..1000)]}FOOBARBAZ", /([a-z]|ab)*FOOBARBAZ/, "/([a-z]|ab)*FOOBARBAZ/", 1000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..10000)]}FOOBARBAZ", /([a-z]|ab)*FOOBARBAZ/, "/([a-z]|ab)*FOOBARBAZ/", 10;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..100)]}NOPE", /([a-z]|ab)*FOOBARBAZ/, "/([a-z]|ab)*FOOBARBAZ/", 1000000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..1000)]}NOPE", /([a-z]|ab)*FOOBARBAZ/, "/([a-z]|ab)*FOOBARBAZ/", 100000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..10000)]}NOPE", /([a-z]|ab)*FOOBARBAZ/, "/([a-z]|ab)*FOOBARBAZ/", 10000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..100)]}NOPE", /[a-z]*FOOBARBAZ/i, "/[a-z]*FOOBARBAZ/i", 1000;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..1000)]}NOPE", /[a-z]*FOOBARBAZ/i, "/[a-z]*FOOBARBAZ/i", 10;
test "@{[join undef, map { chr(ord('a') + rand 26) } (1..10000)]}NOPE", /[a-z]*FOOBARBAZ/i, "/[a-z]*FOOBARBAZ/i", 10;