14 seconds overall, or 14 seconds just for the
undef. When I try this on freebsd I find that it takes twice as long to create the hash than to undef it:
$ perl hash.pl ; perl hash.pl ; perl hash.pl
Create: 5.26445007324219
Destroy: 1.82375288009644
Create: 5.18459510803223
Destroy: 1.82551097869873
Create: 5.14320707321167
Destroy: 1.8236780166626
using a slightly different program:
$ cat hash.pl
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
use Time::HiRes 'time';
my $t0 = time;
my %hash;
$hash{$_} = 1 for 1..3_000_000;
my $t1 = time;
undef %hash;
my $t2 = time;
print "Create: ", $t1-$t0, "\nDestroy: ", $t2-$t1, "\n";
$ uname -a
FreeBSD XXX.XXX.XXX 7.0-RELEASE-p2 FreeBSD 7.0-RELEASE-p2 #0: Wed Jun
+18 06:48:16 UTC 2008 root@amd64-builder.daemonology.net:/usr/obj/
+usr/src/sys/GENERIC amd64
$ perl -v
This is perl, v5.8.8 built for amd64-freebsd
And I get very similar results on linux with perl 5.10.0 and 5.8.8
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.