Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I like cmpthese results rather than timethese so I've reworked your benchmark a little.

The parameter passing tests were doing a lot of non-parameter passing work so I made the variables global (using our variables) and used the constructed hashes from the first two tests as the test variables for the passing tests.

Rate reference regular reference 8.00/s -- -8% regular 8.73/s 9% -- Rate regularPass referencePass regularPass 7.19/s -- -33% referencePass 10.7/s 49% --
use strict; use warnings; use Benchmark qw(cmpthese); my %hash; my $hash; cmpthese (30, {"regular" => \&regular, "reference" => \&reference}); cmpthese (30, {"regularPass" => \&regularPass, "referencePass" => \&re +ferencePass}); sub regular { our %hash; for my $i (1 .. 100000) { $hash{$i} = $i; } } sub reference { our $hash; for my $i (1 .. 100000) { $hash->{$i} = $i; } } sub regularPass { our %hash; for my $i (1 .. 100000) { helper(\%hash); } } sub referencePass { my $hash; for my $i (1 .. 100000) { helper($hash); } } sub helper { my $hash = shift; }

Perl is Huffman encoded by design.

In reply to Re^2: Hashes and hash references by GrandFather
in thread Hashes and hash references by Anonymous Monk

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-03-29 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found