use strict; use Benchmark qw(:all); my %data = ( Lore =>'mipsumdo', ente =>'squemoll', lors =>'itametco', isod =>'ioetnonu', nsec =>'tetuerad', mmyf =>'acilisis', ipis =>'cingelit', augu =>'eliberoi', Sedr =>'honcusma', acul =>'isodioat', ssai =>'dmollisp', cons =>'ectetuer', hare =>'travelit', nisl =>'nislquis', null =>'amattise', feli =>'sDonecma', nimq =>'uisferme', gnar =>'isusulla', ntum =>'nequenul', mcor =>'peridele', lase =>'dduiDone', ifen =>'dutfeugi', cbla =>'nditmetu', atas =>'emAliqua', svit =>'aecondim', msed =>'magnaado', entu =>'mluctusa', lorn =>'onummysa', ntem =>'assaeuis', gitt =>'isNuncne', moda =>'nteaport', corc =>'iMorbima', amii =>'psumnonl', ttis =>'blandits', eoAl =>'iquamcon', emPh =>'asellusq', dime =>'ntumblan', uiso =>'rciInfer', ditf =>'elisPell', ment =>'umturpis', ); sub WithCopy { my $hashref = $_[0]; my @dummy = @{$hashref}{'Lore','lors','nsec'}; } sub WithoutCopy { my @dummy = @{$_[0]}{'Lore','lors','nsec'}; } cmpthese(5000000, { 'WithCopy' => 'WithCopy(\%data);', 'WithoutCopy' => 'WithoutCopy(\%data);', }); __END__ Rate WithCopy WithoutCopy WithCopy 548908/s -- -6% WithoutCopy 581801/s 6% --

In reply to Re^2: Trying to optimize de-referenced hash slice without scope variables... by meetraz
in thread Trying to optimize de-referenced hash slice without scope variables... by monsieur_champs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.