in reply to Re: Trying to optimize de-referenced hash slice without scope variables...
in thread Trying to optimize de-referenced hash slice without scope variables...
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% --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Trying to optimize de-referenced hash slice without scope variables...
by Joost (Canon) on Jun 15, 2004 at 18:04 UTC |