-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This was used to optimise newick parsing.
- Loading branch information
1 parent
e815888
commit a97cfc3
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use 5.016; | ||
use warnings; | ||
use Benchmark qw {:all}; | ||
|
||
#use Data::Dumper; | ||
use Regexp::Common qw /number delimited/; | ||
|
||
use constant CONST_RE_NUMCAPTURE => qr /\G ($RE{num}{real})/xmso; | ||
|
||
my $RE_NUMBER = qr /$RE{num}{real}/xmso; | ||
my $RE_QUOTED = qr /$RE{delimited}{-delim=>"'"}{-esc=>"'"}/o; | ||
|
||
my $RE_NUM_CAPTURE = qr /\G ( $RE_NUMBER ) /xs; | ||
|
||
my $string = '12335567j'; | ||
|
||
cmpthese ( | ||
-5, | ||
{ | ||
orig => sub {orig ()}, | ||
oflag => sub {oflag()}, | ||
qcapt => sub {qcapt()}, | ||
qcapo => sub {qcapto()}, | ||
ccapo => sub {ccapto()}, | ||
}, | ||
); | ||
|
||
|
||
|
||
sub orig { | ||
for (1..10000) { | ||
$string =~ m/\G ( $RE_NUMBER ) /xgcs; | ||
} | ||
} | ||
|
||
sub oflag { | ||
for (1..10000) { | ||
$string =~ m/\G ( $RE_NUMBER ) /xgcso; | ||
} | ||
} | ||
|
||
sub qcapt { | ||
for (1..10000) { | ||
$string =~ m/$RE_NUM_CAPTURE/gc; | ||
} | ||
} | ||
|
||
sub qcapto { | ||
for (1..10000) { | ||
$string =~ m/$RE_NUM_CAPTURE/gco; | ||
} | ||
} | ||
|
||
sub ccapto { | ||
for (1..10000) { | ||
$string =~ m/${\CONST_RE_NUMCAPTURE()}/gc; | ||
} | ||
} |