Skip to content

Instantly share code, notes, and snippets.

@jzawodn
Created September 25, 2012 03:57
Show Gist options
  • Save jzawodn/3779892 to your computer and use it in GitHub Desktop.
Save jzawodn/3779892 to your computer and use it in GitHub Desktop.
silly benchmark of matching parens
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark qw(:all);
my $string = "foo (bar) and (baz) stuff)";
my $left = 0;
my $right = 0;
timethese(10_000_000, {
'left' => sub {
$left++ while $string =~ /\(/g;
},
'right' => sub {
$right++ while $string =~ /\)/g;
}
});
#print "left: $left, right: $right\n";
exit;
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment