]> git.vpit.fr Git - perl/modules/autovivification.git/commitdiff
Bench several levels of dereferenciation
authorVincent Pit <vince@profvince.com>
Sat, 19 Jun 2010 14:58:10 +0000 (16:58 +0200)
committerVincent Pit <vince@profvince.com>
Sat, 19 Jun 2010 14:58:10 +0000 (16:58 +0200)
samples/bench.pl

index bb55856e5ca1b898e7ef351de1a07cdd2ec0294b..9b0f1735c5495155bae27be43c01254d36f751fe 100644 (file)
@@ -5,6 +5,8 @@ use warnings;
 
 use Benchmark qw/cmpthese/;
 
+use blib;
+
 my $count = -1;
 
 {
@@ -46,3 +48,12 @@ my $count = -1;
   fetch_hashref_nonexisting_noav => sub { no autovivification; $x->{a} },
  };
 }
+
+{
+ my $x = { a => { b => { c => { d => 1 } } } };
+
+ cmpthese $count, {
+  fetch_hashref4_existing_av   => sub { $x->{a}{b}{c}{d} },
+  fetch_hashref4_existing_noav => sub { no autovivification; $x->{a}{b}{c}{d} },
+ };
+}