in reply to Initializing iterations while benchmarking
I guess you can always setup your data outside the closures, just before the benchmark takes place, as in:
use strict; use warnings; use Benchmark; my @strings = qw(exception:tex exception:mex asdf tex:exception:mex); my @one = @strings; my @two = @strings; my @three = @strings; Benchmark::cmpthese( -5, { 'one' => sub { my @filtered = grep { /exception:(?!tex)/} @one; }, 'two' => sub { my @filtered = grep { /exception/ && !/tex/ } @two; + }, 'three' => sub { my @filtered = grep { /exception:/g && !/\Gtex/ } + @three; }, });
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Initializing iterations while benchmarking
by ig (Vicar) on Aug 07, 2009 at 10:20 UTC | |
by alexm (Chaplain) on Aug 07, 2009 at 10:33 UTC | |
by ig (Vicar) on Aug 07, 2009 at 10:43 UTC | |
by alexm (Chaplain) on Aug 07, 2009 at 11:05 UTC | |
by ig (Vicar) on Aug 07, 2009 at 11:19 UTC |
In Section
Seekers of Perl Wisdom