in reply to Bug when undefining a large hash

I modified your script a little bit:
use strict; use warnings; use Time::HiRes qw(time); # Create a large hash my %hash; my $count = 3_000_000; $hash{$count} = rand(10) while $count--; # Undefine it print "Undefining hash.\n"; my $before = time; undef %hash; printf "Done in %.03f seconds\n", time - $before;

On my linux box it's about 1.5s for both perl 5.8.8 and perl 5.10.0.

I suspect that might be due to a different malloc in windows and linux, so my next step will be do compile a perl with a different malloc, and try again.

Update: A perl configured with -Uusemymalloc took 1.4s, so no real difference.

Replies are listed 'Best First'.
Re^2: Bug when undefining a large hash
by oxone (Friar) on Aug 22, 2008 at 13:55 UTC
    Your times reflect my own for Windows, and your Linux test suggests that Linux does not show this problem either. This is perhaps a problem specifically with Perl on FreeBSD?
Re^2: Bug when undefining a large hash
by dextius (Monk) on Aug 27, 2008 at 13:15 UTC
    my macbook pro (2.16Ghz Core2duo) took 3.17 seconds.. Darwin being a BSD derived OS.