Codebase list liblist-objects-withutils-perl / 3a42602
kill stale benchmark script Jon Portnoy 8 years ago
1 changed file(s) with 0 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
+0
-26
bench/foreach_vs_visit.pl less more
0 use strict; use warnings;
1
2 use List::Objects::WithUtils;
3 use Benchmark 'cmpthese', 'timethese';
4
5 my $foreach = sub {
6 my $array = array(1 .. 100_000);
7 for ($array->all) {
8 my $foo = $_ + 1
9 }
10 ()
11 };
12
13 my $visit = sub {
14 my $array = array(1 .. 100_000);
15 $array->visit(sub { my $foo = $_ + 1 });
16 ()
17 };
18
19 my $results = timethese( 500 =>
20 +{
21 foreach => $foreach,
22 visit => $visit,
23 }
24 );
25 cmpthese($results);