start on rx benchmark suite
svn: r4319
This commit is contained in:
parent
8f55d3f6c3
commit
1558cf2b10
86
collects/tests/mzscheme/benchmarks/rx/auto.ss
Normal file
86
collects/tests/mzscheme/benchmarks/rx/auto.ss
Normal file
|
@ -0,0 +1,86 @@
|
|||
|
||||
(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))))))
|
||||
|
||||
(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)))))
|
||||
|
||||
(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)
|
||||
)
|
83
collects/tests/mzscheme/benchmarks/rx/perl_prefix.pl
Normal file
83
collects/tests/mzscheme/benchmarks/rx/perl_prefix.pl
Normal file
|
@ -0,0 +1,83 @@
|
|||
|
||||
use Time::HiRes qw(time);
|
||||
|
||||
sub test ($$$$) {
|
||||
local ($x, $pattern, $pstr, $times) = @_;
|
||||
|
||||
print "$pstr $times iterations on " . length($x) . " bytes:\n";
|
||||
|
||||
$start = time;
|
||||
for ($i = 0; $i < $times; $i++) {
|
||||
$x =~ ${pattern};
|
||||
}
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user