Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re:x2 Counting keys with defined or undefined elements in a hash

by grinder (Bishop)
on Jun 05, 2003 at 16:59 UTC ( [id://263412] : note . print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    ! /usr/bin/perl -w
    
    ...
    __END__
    produces:
    undefined=2, defined=3
    
  2. or download this
    #! /usr/bin/perl -w
    
    ...
            grep => ' by_grep( \%h ) ',
        }
    );
    
  3. or download this
    by_for:  undefined=2000300, defined=7999700
    by_grep: undefined=2000300, defined=7999700
    ...
             Rate  for grep
    for  163521/s   -- -27%
    grep 224222/s  37%   --
    
  4. or download this
    cmpthese( -300, {
            byfor  => sub { by_for( \%h ) },
            bygrep => sub { by_grep( \%h ) },
        }
    );
    
  5. or download this
    by_for:  undefined=2398233, defined=9601767
    by_grep: undefined=2398233, defined=9601767
    ...
           s/iter bygrep  byfor
    bygrep   24.1     --   -35%
    byfor    15.6    55%     --
    
  6. or download this
    sub by_diff {
       my $h = shift;
    ...
           bydiff => sub { by_diff( \%h ) },
       }
    );
    
  7. or download this
    by_for:  undefined=2398740, defined=9601260
    by_grep: undefined=2398740, defined=9601260
    ...
    bygrep   24.1     --   -35%   -51%
    byfor    15.6    55%     --   -24%
    bydiff   11.9   103%    31%     --