Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: Re: Printing a hash in a specific order?

by artist (Parson)
on Mar 15, 2003 at 15:44 UTC ( #243303=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Printing a hash in a specific order?
in thread Printing a hash in a specific order?

Hi L~R,
You can input your data in benchmarking here.

My benchmark, comparing 200,00 records and each record contain a 50 fields containing small numeric data as key and value, gives the results:

Benchmark: timing 200000 iterations of with_tie, without_tie...
  with_tie: 98 wallclock secs (96.22 usr +  0.00 sys = 96.22 CPU) @ 2078.61/s (n=200000)
without_tie: 14 wallclock secs (13.25 usr +  0.00 sys = 13.25 CPU) @ 15094.34/s (n=200000)
               Rate    with_tie without_tie
with_tie     2079/s          --        -86%
without_tie 15094/s        626%          --
And the code is

use Benchmark qw(cmpthese); use strict; use Tie::IxHash; sub with_tie { tie my %menu, 'Tie::IxHash'; foreach (1..50){$menu{$_} = $_; } } sub without_tie{ my %menu; foreach (1..50){$menu{$_} = $_;} } cmpthese(200000, { with_tie => \&with_tie, without_tie => \&without_tie });
artist


Comment on Re: Re: Re: Printing a hash in a specific order?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://243303]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2015-07-03 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (56 votes), past polls