in reply to Bug when undefining a large hash

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

Replies are listed 'Best First'.
Re^2: Bug when undefining a large hash
by oxone (Friar) on Aug 22, 2008 at 14:00 UTC
    My 14 secs is just for the undef.

    I'm testing on FreeBSD 6.2-RELEASE-p1 with Perl "v5.8.8 built for i386-freebsd".