Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix and improve charrange microbenchmarks
They were originally creating bogus data, testing only successful and
not unsuccessful matches, and tended to take an untenable time to finish.
All of these issues are now fixed, though the extra complexity needed for
these tests makes me wonder if we need special structure for regex tests.

Note to test submitters: If you're unsure of your test and are just
committing to share the WIP, please mark the test 'enabled => 0' so that
general users won't get tripped up.
  • Loading branch information
Geoffrey Broadwell committed Jul 27, 2014
1 parent f06e6d7 commit 7e86722
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions microbenchmarks.pl
Expand Up @@ -311,23 +311,19 @@
},
{
name => 'charrange',
tags => [qw( regex cclass )],
scale => 1,
work => sub { $_[0] += int($_[0] / 2) || 1 },
scaling => 'linear',
perl5 => 'my $c = sprintf("%x",SCALE); my $reg="[\\x00-\\x{$c}]"; "\x{$c}" ~~ /$reg/',
perl6 => '"\c[SCALE]" ~~ /<[\c0..\c[SCALE]]>/',
nqp => '"\c[SCALE]" ~~ /<[\c0..\c[SCALE]]>/',
tags => [qw( while string regex cclass )],
scale => 1 << 7,
perl5 => 'my $y = chr(SCALE); my $n = chr(SCALE + 1); my $c = sprintf("%x",SCALE); my $reg="[\\x00-\\x{$c}]"; my $i = 0; while (++$i <= SCALE) { $y ~~ /$reg/; $n ~~ /$reg/; }',
perl6 => 'my $y = chr(SCALE); my $n = chr(SCALE + 1); my $i = 0; while (++$i <= SCALE) {$y ~~ /<[\c0..\c[SCALE]]>/; $n ~~ /<[\c0..\c[SCALE]]>/ }',
nqp => 'my $y := nqp::chr(SCALE); my $n := nqp::chr(SCALE + 1); my $i := 0; while ($i := $i + 1) <= SCALE { $y ~~ /<[\c0..\c[SCALE]]>/; $n ~~ /<[\c0..\c[SCALE]]>/ }',
},
{
name => 'charrange_ignorecase',
tags => [qw( regex cclass )],
scale => 1,
work => sub { $_[0] += int($_[0] / 2) || 1 },
scaling => 'linear',
perl5 => 'my $c = sprintf("%x",SCALE); my $reg="[\\x00-\\x{$c}]"; "\x{$c}" ~~ /$reg/i',
perl6 => '"\c[SCALE]" ~~ /:i<[\c0..\c[SCALE]]>/',
nqp => '"\c[SCALE]" ~~ /:i<[\c0..\c[SCALE]]>/',
tags => [qw( while string regex cclass )],
scale => 1 << 7,
perl5 => 'my $y = chr(SCALE); my $n = chr(SCALE + 1); my $c = sprintf("%x",SCALE); my $reg="[\\x00-\\x{$c}]"; my $i = 0; while (++$i <= SCALE) { $y ~~ /$reg/i; $n ~~ /$reg/i; }',
perl6 => 'my $y = chr(SCALE); my $n = chr(SCALE + 1); my $i = 0; while (++$i <= SCALE) {$y ~~ /:i<[\c0..\c[SCALE]]>/; $n ~~ /:i<[\c0..\c[SCALE]]>/ }',
nqp => 'my $y := nqp::chr(SCALE); my $n := nqp::chr(SCALE + 1); my $i := 0; while ($i := $i + 1) <= SCALE { $y ~~ /:i<[\c0..\c[SCALE]]>/; $n ~~ /:i<[\c0..\c[SCALE]]>/ }',
},
{
name => 'visit_2d_indices_while',
Expand Down

0 comments on commit 7e86722

Please sign in to comment.