Hi!

Looks like used hashes (and, probably, arrays?) is slowdown some operations (like keys()), even if they was cleaned after using... and only way to workaround this slowdown is use undef() to clean up things.

I've not found description of this effect in docs, so maybe this is a bug ... or please point me to explanation of this feature in docs. :-)

Perl 5.8.2, Glibc 2.2.5, Linux 2.4.22

WBR, Alex.

#!/usr/bin/perl use Benchmark qw(:all); %h_delete = %h_list = %h_undef = (0 .. 50000); delete @h_delete{keys %h_delete}; %h_list = (); undef %h_undef; timethese 10000, { delete => '1 for keys %h_delete', list => '1 for keys %h_list', undef => '1 for keys %h_undef', }; __END__ Benchmark: timing 10000 iterations of delete, list, undef... delete: 5 wallclock secs ( 2.43 usr + 0.00 sys = 2.43 CPU) @ 41 +15.23/s (n=10000) list: 5 wallclock secs ( 2.44 usr + 0.00 sys = 2.44 CPU) @ 40 +98.36/s (n=10000) undef: 0 wallclock secs ( 0.02 usr + 0.00 sys = 0.02 CPU) @ 50 +0000.00/s (n=10000) (warning: too few iterations for a reliable count)

In reply to undef speedup ?! by powerman

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.