in reply to Initializing iterations while benchmarking
As an alternate approach entirely: Devel::NYTProf will give you total time used by blocks and lines of code, so it could be used for some benchmarking.
use strict; use warnings; my @strings = qw(exception:tex exception:mex asdf tex:exception:mex); for ( my $i; $i < 500; $i++ ) { my @unfiltered = @strings; my @filtered = grep { /exception:(?!tex)/} @unfiltered; }; my @unfiltered = @strings; my @filtered1 = grep { /exception/ && !/tex/ } @unfiltered; }; my @unfiltered = @strings; my @filtered2 = grep { /exception:/g && !/\Gtex/ } @unfiltered; }; }
Run that with perl -d:NYTProf, and you'll be able to get output that will list how long it took on average for each grep, and the total time for each grep, having run through them 500 times. It won't quite be as neat for benchmarking as Benchmark, but it'll give you the data. (Note: Code has only been run in Perlmonks, not perl.)
|
|---|