finish up rx benchmark

svn: r4337
This commit is contained in:
Matthew Flatt 2006-09-14 08:08:56 +00:00
parent 4aad4bb6df
commit 7e6ab6ee47
4 changed files with 136 additions and 102 deletions

View File

@ -10,11 +10,14 @@ exec mzscheme -qu "$0" ${1+"$@"}
(define base-link-filename (make-parameter #f))
(define full-page-mode (make-parameter #f))
(define include-links (make-parameter #f))
(command-line
"tabulate"
(current-command-line-arguments)
(once-each
[("--no-links") "suppress benchmark links to SVN"
(include-links #f)]
[("--multi") name "generate multiple pages for different views of data"
(base-link-filename name)]
[("--index") "generate full page with an index.html link"
@ -150,10 +153,12 @@ exec mzscheme -qu "$0" ${1+"$@"}
(values (caadr a) (caddr a))
(values #f #f)))
(values fastest c-fastest))])
`(tr (td (a ((href ,(format (string-append "http://svn.plt-scheme.org/plt/trunk/collects/"
"tests/mzscheme/benchmarks/common/~a.sch")
(car bm-run))))
,(symbol->string (car bm-run))))
`(tr (td ,(if (include-links)
`(a ((href ,(format (string-append "http://svn.plt-scheme.org/plt/trunk/collects/"
"tests/mzscheme/benchmarks/common/~a.sch")
(car bm-run))))
,(symbol->string (car bm-run)))
(symbol->string (car bm-run))))
(td ((align "right"))
nbsp
,(small (if (= c-fastest forever)
@ -168,12 +173,14 @@ exec mzscheme -qu "$0" ${1+"$@"}
(map (lambda (impl)
(let* ([a (assq impl (cdr bm-run))]
[n (and a (caadr a))])
`((td ((align "right")
(bgcolor ,(lookup-color impl)))
,(if (and (caddr a) c-base (positive? c-base))
(small (ratio->string (/ (caddr a) c-base)))
'"-")
nbsp)
`(,(if (= c-fastest forever)
`(td)
`(td ((align "right")
(bgcolor ,(lookup-color impl)))
,(if (and (caddr a) c-base (positive? c-base))
(small (ratio->string (/ (caddr a) c-base)))
'"-")
nbsp))
(td ((bgcolor ,(lookup-color impl)))
,(if (and n base)
(let ([s (if (= n base)

View File

@ -19,6 +19,9 @@ exec mzscheme -qu "$0" ${1+"$@"}
(loop (sub1 n))))
(- (current-inexact-milliseconds) start))))
(define (encode-newlines rx)
(regexp-replace* #rx#"\n" rx #"\\\\n"))
(define (test-perl input rx iterations)
(with-output-to-file "test.pl"
(lambda ()
@ -26,8 +29,8 @@ exec mzscheme -qu "$0" ${1+"$@"}
(lambda ()
(copy-port (current-input-port)
(current-output-port))))
(printf "test \"~a\", qr/~a/, \"/~a/\", ~a;\n"
input rx rx iterations))
(printf "test \"~a\", qr/~a/, ~a;\n"
(encode-newlines input) rx iterations))
'truncate)
(let ([s (open-output-bytes)])
(parameterize ([current-output-port s])
@ -47,7 +50,7 @@ exec mzscheme -qu "$0" ${1+"$@"}
(copy-port (current-input-port)
(current-output-port))))
(printf "test(~s, \"~a\", ~a)\n"
(bytes->string/latin-1 (pythonize rx)) input iterations))
(bytes->string/latin-1 (pythonize rx)) (encode-newlines input) iterations))
'truncate)
(let ([s (open-output-bytes)])
(parameterize ([current-output-port s])
@ -77,94 +80,117 @@ exec mzscheme -qu "$0" ${1+"$@"}
accum))))))
(define (add-index l)
(let loop ([i 1][l l])
(let loop ([i 1][j 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))))))
(let ([next-is-diff?
(or (null? (cdr l))
(not (eq? (caar l) (caadr l))))])
(cons (list* (if (and (= i 1) next-is-diff?)
(caar l)
(string->symbol (format "~a~a" (caar l) i)))
(let ([n (format "0~a" j)])
(substring n (- (string-length n) 2)))
(cdar l))
(loop (if next-is-diff? 1 (add1 i))
(add1 j)
(cdr l)))))))
(define inputs
(add-index
(list
(list (make-bytes 10 (char->integer #\x)) #"." 1000000 '())
(list #"cataract cataract23" #"(cat(a(ract|tonic)|erpillar)) \\1()2(3)" 100000 '())
(list #"cataract cataract23" #"(cat(?:a(?:ract|tonic)|erpillar)) \\1(?:)23" 100000 '())
(list #"cataract cataract23" #"(?i:(cat(?:a(?:ract|tonic)|erpillar))) \\1(?:)23" 100000 '())
(list #"From abcd Mon Sep 1 12:33:02 1997" #"^From\\s+\\S+\\s+([a-zA-Z]{3}\\s+){2}\\d{1,2}\\s+\\d\\d:\\d\\d" 100000 '())
(list #"From abcd Sep 01 12:33:02 1997" #"^From\\s+\\S+\\s+([a-zA-Z]{3}\\s+){2}\\d{1,2}\\s+\\d\\d:\\d\\d" 100000 '())
(list #"foobar is foolish see?" #"foo(?!bar)(.*)" 100000 '())
(list #"foobar crowbar etc" #"(?:(?!foo)...|^.{0,2})bar(.*)" 100000 '())
(list #"now is the time for all good men to come to the aid of the party" #"^((?>\\w+)|(?>\\s+))*$" 30000 '(python))
(list #"this is not a line with only words and spaces!" #"^((?>\\w+)|(?>\\s+))*$" 30000 '(python))
(list #"yesBABthe AAABquickAAAB brown foxABB" #"yesB([^AB]+|A.)*B" 10000 '())
(list #"noBABthe AAABquickAAAB brown foxAB" #"noB([^AB]+|A.)*B" 10 '())
(list #"yesBABthe AAABquickAAAB brown foxABB" #"yesB(?:[^AB]+|A.)*B" 10000 '())
(list #"noBABthe AAABquickAAAB brown foxAB" #"noB(?:[^AB]+|A.)*B" 10 '())
(list #"yesbabthe aaabquickaaab frown foxabb" #"(?i:yesB(?:[^AB]+|A.)*B)" 10000 '())
(list #"nobabthe aaabquickaaab frown foxab" #"(?i:noB(?:[^AB]+|A.)*B)" 10 '())
(list #"track1.title:TBlah blah blah" #"([^.]*)\\.([^:]*):[T ]+(.*)" 100000 '())
(list (make-bytes 1000 (char->integer #\a)) #"^(a|x)\\1*a$" 1000 '())
(list (make-bytes 1000 (char->integer #\a)) #"^(a*|x)\\1a$" 1000 '())
(list (make-bytes 1000 (char->integer #\a)) #"^(a*|x)\\1a" 1000 '())
(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 '(pcre python))
(list (make-bytes 10000 (char->integer #\x)) #"(?s:(.)*)" 10000 '(pcre python))
(list (make-bytes 100000 (char->integer #\x)) #"(?s:(.)*)" 1000 '(pcre python))
(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 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)) #"(y|x)*" 10000 '())
(list (make-bytes 100 (char->integer #\x)) #"(?:y|x)*" 10000 '())
(list (make-bytes 1000 (char->integer #\x)) #"(?:y|x)*" 1000 '(python))
(list (make-bytes 10000 (char->integer #\x)) #"(?:y|x)*" 100 '(python))
(list (make-bytes 100000 (char->integer #\x)) #"(?:y|x)*" 10 '(pcre python))
(list (make-bytes 100 (char->integer #\x)) #"([yz]|x)*" 10000 '())
(list (make-bytes 100 (char->integer #\x)) #"(?:[yz]|x)*" 10000 '())
(list (make-bytes 1000 (char->integer #\x)) #"(?:[yz]|x)*" 1000 '(python))
(list (make-bytes 10000 (char->integer #\x)) #"(?:[yz]|x)*" 100 '(python))
(list (make-bytes 100000 (char->integer #\x)) #"(?:[yz]|x)*" 10 '(pcre python))
(list (make-bytes 100 (char->integer #\x)) #"((x){2})*" 10000 '())
(list (make-bytes 100 (char->integer #\x)) #"(x{2})*" 10000 '())
(list (make-bytes 100 (char->integer #\x)) #"(?:x{2})*" 10000 '())
(list (make-bytes 1000 (char->integer #\x)) #"(?:x{2})*" 10000 '(python))
(list (make-bytes 10000 (char->integer #\x)) #"(?:x{2})*" 100 '(python))
(list (make-bytes 100000 (char->integer #\x)) #"(?:x{2})*" 100 '(pcre python))
(list (bytes-append (random-letters 100) #"FOOBARBAZ") #"([a-z])*FOOBARBAZ" 100000 '())
(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) #"FOOBARBAZ") #"([a-z])*FOOBARNOPE" 1000000 '(python))
(list (bytes-append (random-letters 100) #"FOOBARBAZ") #"[a-z]*FOOBARNOPE" 1000000 '(python))
(list (bytes-append (random-letters 1000) #"FOOBARBAZ") #"[a-z]*FOOBARNOPE" 100000 '(pcre python))
(list (bytes-append (random-letters 10000) #"FOOBARBAZ") #"[a-z]*FOOBARNOPE" 10000 '(pcre python))
(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 '(python))
(list (bytes-append (random-letters 100) #"FOOBARBAZ") #"(?:[a-z]|ab)*FOOBARNOPE" 1000000 '(python))
(list (bytes-append (random-letters 1000) #"FOOBARBAZ") #"(?:[a-z]|ab)*FOOBARNOPE" 100000 '(pcre python))
(list (bytes-append (random-letters 10000) #"FOOBARBAZ") #"(?:[a-z]|ab)*FOOBARNOPE" 10000 '(pcre python))
(list (bytes-append (random-letters 100) #"FOOBARBAZ") #"(?i:[a-z]*FOOBARNOPE)" 10000 '())
(list (bytes-append (random-letters 1000) #"FOOBARBAZ") #"(?i:[a-z]*FOOBARNOPE)" 1000 '(pcre perl python))
(list (bytes-append (random-letters 10000) #"FOOBARBAZ") #"(?i:[a-z]*FOOBARNOPE)" 1000 '(pcre perl python)))))
(list 'overhead (make-bytes 10 (char->integer #\x)) #"." 100000 '())
(list 'overhead (make-bytes 10 (char->integer #\x)) #"." 1000000 '())
(list 'simple #"track1.title:TBlah blah blah" #"([^.]*)\\.([^:]*):[T ]+(.*)" 100000 '())
(list 'far (bytes-append (make-bytes 10000 (char->integer #\a)) #"z") #"z" 10000 '())
(list 'farzq (bytes-append (make-bytes 1000 (char->integer #\a)) #"z") #"[zq]" 10000 '())
(list 'farzqalt (bytes-append (make-bytes 1000 (char->integer #\a)) #"z") #"z|q" 10000 '())
(list 'fard (bytes-append (make-bytes 1000 (char->integer #\a)) #"0") #"\\d" 10000 '())
(list 'farw (bytes-append (make-bytes 1000 (char->integer #\space)) #"_") #"\\w" 10000 '())
(list 'farnz (bytes-append (make-bytes 10000 (char->integer #\a)) #"z") #"(?:)z" 1000 '())
(list 'backtrack (bytes-append (make-bytes 300 (char->integer #\a)) #"zay") #"a*y" 1000 '())
(list 'backtrack (bytes-append (make-bytes 300 (char->integer #\a)) #"zay") #"a*?z" 10000 '())
(list 'backtrack (bytes-append (make-bytes 300 (char->integer #\a)) #"zay") #"a*?y" 1000 '())
(list 'alts #"cataract cataract23" #"(cat(a(ract|tonic)|erpillar)) \\1()2(3)" 100000 '())
(list 'alts #"cataract cataract23" #"(cat(?:a(?:ract|tonic)|erpillar)) \\1(?:)23" 100000 '())
(list 'alts #"caterpillar caterpillar23" #"(cat(?:a(?:ract|tonic)|erpillar)) \\1(?:)23" 100000 '())
(list 'alts #"cataract cataract23" #"(?i:(cat(?:a(?:ract|tonic)|erpillar))) \\1(?:)23" 100000 '())
(list 'digits #"From abcd Mon Sep 1 12:33:02 1997" #"^From\\s+\\S+\\s+([a-zA-Z]{3}\\s+){2}\\d{1,2}\\s+\\d\\d:\\d\\d" 100000 '())
(list 'digits #"From abcd Sep 01 12:33:02 1997" #"^From\\s+\\S+\\s+([a-zA-Z]{3}\\s+){2}\\d{1,2}\\s+\\d\\d:\\d\\d" 100000 '())
(list 'lines (bytes-append (make-bytes 100 (char->integer #\x)) #"\na\nb\nc\nxxxxxxxx") #"(?m:^a(?:$)[^a]^b(?:$)[^a]^c(?:$))" 10000 '())
(list 'lookahead #"foobar is foolish see?" #"foo(?!bar).*" 100000 '())
(list 'lookahead #"foobar crowbar etc" #"(?:(?!foo)...|^.{0,2})bar.*" 100000 '())
(list 'lookbehind #"foobar is foolish see?" #"(?<=foo)lish.*" 100000 '())
(list 'lookbehind #"foobar crowbar etc" #"(?<=bar ....)bar.*" 100000 '())
(list 'cond (bytes-append #"E" (make-bytes 100 (char->integer #\x))) #"^(E)?(?(1)xx|x)*$" 10000 '(python))
(list 'cond (bytes-append #"E" (make-bytes 101 (char->integer #\x))) #"^(E)?(?(1)xx|x)*$" 10000 '(python))
(list 'cond (make-bytes 101 (char->integer #\x)) #"^(E)?(?(1)xx|x)*$" 10000 '(python))
(list 'cut #"now is the time for all good men to come to the aid of the party" #"^((?>\\w+)|(?>\\s+))*$" 30000 '(python))
(list 'cut #"this is not a line with only words and spaces!" #"^((?>\\w+)|(?>\\s+))*$" 30000 '(python))
(list 'escape #"yesBABthe AAABquickAAAB brown foxABB" #"yesB([^AB]+|A.)*B" 10000 '())
(list 'escape #"noBABthe AAABquickAAAB brown foxAB" #"noB([^AB]+|A.)*B" 10 '())
(list 'escape #"yesBABthe AAABquickAAAB brown foxABB" #"yesB(?:[^AB]+|A.)*B" 10000 '())
(list 'escape #"noBABthe AAABquickAAAB brown foxAB" #"noB(?:[^AB]+|A.)*B" 10 '())
(list 'escape #"yesbabthe aaabquickaaab frown foxabb" #"(?i:yesB(?:[^AB]+|A.)*B)" 10000 '())
(list 'escape #"nobabthe aaabquickaaab frown foxab" #"(?i:noB(?:[^AB]+|A.)*B)" 10 '())
(list 'stress-same (make-bytes 1000 (char->integer #\x)) #"^(x|a)\\1*x$" 1000 '())
(list 'stress-same (make-bytes 1000 (char->integer #\x)) #"^(x*|a)\\1x$" 1000 '())
(list 'stress-same (make-bytes 1000 (char->integer #\x)) #"^(x*|a)\\1x" 1000 '())
(list 'stress-any (make-bytes 1000 (char->integer #\x)) #"(?s:.*)" 100000 '())
(list 'stress-any (make-bytes 10000 (char->integer #\x)) #"(?s:.*)" 100000 '())
(list 'stress-any (make-bytes 100000 (char->integer #\x)) #"(?s:.*)" 100000 '())
(list 'stress-nonlf (make-bytes 100 (char->integer #\x)) #"(?m:.*)" 100000 '())
(list 'stress-nonlf (make-bytes 1000 (char->integer #\x)) #"(?m:.*)" 100000 '())
(list 'stress-nonlf (make-bytes 10000 (char->integer #\x)) #"(?m:.*)" 100000 '())
(list 'stress-nonlf (make-bytes 100000 (char->integer #\x)) #"(?m:.*)" 10000 '())
(list 'stress-anysave (make-bytes 100 (char->integer #\x)) #"(?s:(.)*)" 100000 '())
(list 'stress-anysave (make-bytes 1000 (char->integer #\x)) #"(?s:(.)*)" 100000 '(pcre python))
(list 'stress-anysave (make-bytes 10000 (char->integer #\x)) #"(?s:(.)*)" 10000 '(pcre python))
(list 'stress-anysave (make-bytes 100000 (char->integer #\x)) #"(?s:(.)*)" 1000 '(pcre python))
(list 'stress-xs (make-bytes 100 (char->integer #\x)) #"x*" 100000 '())
(list 'stress-xs (make-bytes 1000 (char->integer #\x)) #"x*" 100000 '())
(list 'stress-xs (make-bytes 10000 (char->integer #\x)) #"x*" 10000 '())
(list 'stress-xs (make-bytes 100000 (char->integer #\x)) #"x*" 1000 '())
(list 'stress-xy (make-bytes 100 (char->integer #\x)) #"[xy]*" 100000 '())
(list 'stress-xy (make-bytes 1000 (char->integer #\x)) #"[xy]*" 10000 '())
(list 'stress-xy (make-bytes 10000 (char->integer #\x)) #"[xy]*" 1000 '())
(list 'stress-xy (make-bytes 100000 (char->integer #\x)) #"[xy]*" 100 '())
(list 'stress-xysave (make-bytes 100 (char->integer #\x)) #"([xy])*" 100000 '())
(list 'stress-xory (make-bytes 100 (char->integer #\x)) #"(?:y|x)*" 10000 '())
(list 'stress-xory (make-bytes 1000 (char->integer #\x)) #"(?:y|x)*" 1000 '(python))
(list 'stress-xory (make-bytes 10000 (char->integer #\x)) #"(?:y|x)*" 100 '(python))
(list 'stress-xory (make-bytes 100000 (char->integer #\x)) #"(?:y|x)*" 10 '(pcre python))
(list 'stress-xorysave (make-bytes 100 (char->integer #\x)) #"(y|x)*" 10000 '())
(list 'stress-yzorx (make-bytes 100 (char->integer #\x)) #"(?:[yz]|x)*" 10000 '())
(list 'stress-yzorx (make-bytes 1000 (char->integer #\x)) #"(?:[yz]|x)*" 1000 '(python))
(list 'stress-yzorx (make-bytes 10000 (char->integer #\x)) #"(?:[yz]|x)*" 100 '(python))
(list 'stress-yzorx (make-bytes 100000 (char->integer #\x)) #"(?:[yz]|x)*" 10 '(pcre python))
(list 'stress-yzorxsave (make-bytes 100 (char->integer #\x)) #"([yz]|x)*" 10000 '())
(list 'stress-x2 (make-bytes 100 (char->integer #\x)) #"(?:x{2})*" 10000 '())
(list 'stress-x2 (make-bytes 1000 (char->integer #\x)) #"(?:x{2})*" 10000 '(python))
(list 'stress-x2 (make-bytes 10000 (char->integer #\x)) #"(?:x{2})*" 100 '(python))
(list 'stress-x2 (make-bytes 100000 (char->integer #\x)) #"(?:x{2})*" 100 '(pcre python))
(list 'stress-x2saveall (make-bytes 100 (char->integer #\x)) #"(x{2})*" 10000 '())
(list 'stress-x2save (make-bytes 100 (char->integer #\x)) #"((x){2})*" 10000 '())
(list 'stress-foobarbaz (bytes-append (random-letters 100) #"FOOBARBAZ") #"[a-z]*FOOBARBAZ" 100000 '())
(list 'stress-foobarbaz (bytes-append (random-letters 1000) #"FOOBARBAZ") #"[a-z]*FOOBARBAZ" 10000 '())
(list 'stress-foobarbaz (bytes-append (random-letters 10000) #"FOOBARBAZ") #"[a-z]*FOOBARBAZ" 1000 '())
(list 'stress-foobarbazsave (bytes-append (random-letters 100) #"FOOBARBAZ") #"([a-z])*FOOBARBAZ" 100000 '())
(list 'stress-nope (bytes-append (random-letters 100) #"FOOBARBAZ") #"[a-z]*FOOBARNOPE" 1000000 '(python))
(list 'stress-nope (bytes-append (random-letters 1000) #"FOOBARBAZ") #"[a-z]*FOOBARNOPE" 100000 '(pcre python))
(list 'stress-nope (bytes-append (random-letters 10000) #"FOOBARBAZ") #"[a-z]*FOOBARNOPE" 10000 '(pcre python))
(list 'stress-nopesave (bytes-append (random-letters 100) #"FOOBARBAZ") #"([a-z])*FOOBARNOPE" 1000000 '(python))
(list 'stress-altfoobarbaz (bytes-append (random-letters 100) #"FOOBARBAZ") #"(?:[a-z]|ab)*FOOBARBAZ" 10000 '())
(list 'stress-altfoobarbaz (bytes-append (random-letters 1000) #"FOOBARBAZ") #"(?:[a-z]|ab)*FOOBARBAZ" 1000 '())
(list 'stress-altfoobarbaz (bytes-append (random-letters 10000) #"FOOBARBAZ") #"(?:[a-z]|ab)*FOOBARBAZ" 10 '(python))
(list 'stress-altnope (bytes-append (random-letters 100) #"FOOBARBAZ") #"(?:[a-z]|ab)*FOOBARNOPE" 1000000 '(python))
(list 'stress-altnope (bytes-append (random-letters 1000) #"FOOBARBAZ") #"(?:[a-z]|ab)*FOOBARNOPE" 100000 '(pcre python))
(list 'stress-altnope (bytes-append (random-letters 10000) #"FOOBARBAZ") #"(?:[a-z]|ab)*FOOBARNOPE" 10000 '(pcre python))
(list 'stress-nopeci (bytes-append (random-letters 100) #"FOOBARBAZ") #"(?i:[a-z]*FOOBARNOPE)" 10000 '())
(list 'stress-nopeci (bytes-append (random-letters 1000) #"FOOBARBAZ") #"(?i:[a-z]*FOOBARNOPE)" 1000 '(pcre perl python))
(list 'stress-nopeci (bytes-append (random-letters 10000) #"FOOBARBAZ") #"(?i:[a-z]*FOOBARNOPE)" 1000 '(pcre perl python)))))
(define benchmark-names (map (lambda (t)
(string->symbol (car t)))
inputs))
(define benchmark-names (map car inputs))
(define testers
(list (list 'mzscheme test-mzscheme)
@ -183,9 +209,12 @@ exec mzscheme -qu "$0" ${1+"$@"}
;; Run benchmarks -------------------------------
(define (log10 n)
(inexact->exact (round (/ (log n) (log 10)))))
(define (run who which)
(let ([t (assoc (symbol->string which) inputs)])
(let-values ([(index input rx iterations skips) (apply values t)])
(let ([t (assoc which inputs)])
(let-values ([(name index input rx iterations skips) (apply values t)])
#;
(printf "Testing ~a: ~s on ~a iterations of a ~a-byte input\n"
who
@ -197,7 +226,7 @@ exec mzscheme -qu "$0" ${1+"$@"}
((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))
(string->symbol (format "~a ~a/~a/~a" index name (log10 (bytes-length input)) (log10 iterations)))
(and ms (inexact->exact (round ms))))))))
(rprintf "; ~a\n" (date->string (seconds->date (current-seconds)) #t))

View File

@ -1,10 +1,8 @@
use Time::HiRes qw(time);
sub test ($$$$) {
local ($x, $pattern, $pstr, $times) = @_;
# print "Trying $pattern $times iterations on " . length($x) . " bytes:\n";
sub test ($$$) {
local ($x, $pattern, $times) = @_;
$start = time;
for ($i = 0; $i < $times; $i++) {

View File

@ -5,6 +5,6 @@ import time
def test(rx, input, iterations):
crx = re.compile(rx)
start = time.time()
for i in range(0, iterations):
for i in range(iterations):
re.search(crx, input)
print(time.time() - start)