Subject: | Hash very slow |
the attached test shown a tangible slowndown when accessing a hash with
a huge amount of keys.
Test
ActiveState
T0 3.47 s.
T1 121.81 s.
Strawberry 5.10
T0 3.59 s.
T1 35.29 s.
linux (hp, solaris, gentoo)
T1 and T2: around 2 s
Cause maybe Win32 memory manager
usemallocwrap='define';
usemymalloc='n';
Another surprize is the fact that presizing a hash make the run time
shorter on gentoo but longer on windows
Subject: | hash_slowdown.pl |
my %hash1;
my %hash2;
use Time::HiRes qw(gettimeofday tv_interval) ;
my $t0 = [gettimeofday];
#~ keys(%hash1) = 500000 ;
for($i=0;$i<500000;$i++)
{
$ee=unpack("H10", pack("N", $i))x3;
$hash1{$ee}="00000000"x25;
$n=0;
substr ($hash1{$ee},8*$n,8)="SSSSSSSS";
}
printf("T0 %0.2f s.\n", tv_interval ($t0, [gettimeofday])) ;
my $t1 = [gettimeofday];
undef %hash1;
#~ keys(%hash2) = 500000 ;
for($i=0;$i<500000;$i++)
{
$ee=unpack("H10", pack("N", $i))x3;
$hash2{$ee}="00000000"x25;
$n=0;
substr ($hash2{$ee},8*$n,8)="SSSSSSSS";
}
printf("T1 %0.2f s.\n", tv_interval ($t1, [gettimeofday])) ;