in reply to Profiling regular expressions
It's a bit ugly, but a Text::Template could generate it for you from a list of expressions extracted from your code.package Regs; use strict; require Exporter; our @ISA = qw(Exporter); our @EXPORT = (); our %EXPORT_TAGS = ( 'all' => [ qw( re1 re2 ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our $VERSION = '0.10'; sub re1 { $_[0] =~ s/foo/bar/g; } sub re2 { $_[0] =~ s/xxx/yyy/g; }
Then you could use Devel::AutoProfiler on a modified version of your script, like this:
Devel::Autoprofiler will automatically generate profile wrappers (you should make sure Regs is the only module after it). Just run the program and it will generate a usage and timing report at the end of the output.use strict; use Devel::AutoProfiler; use Regs qw(:all); my $a = "fooxxxfoo"; my $b = "foo foo foo"; re1($a); re2($a); print "a is $a\n"; re1($b); re2($b); print "b is $b\n";
|
|---|