G
gamo
I have installed 5.18, and think that if hashes are randomized, maybe
a simple hash could substitute the shuffle operations, but I'm not sure
if the comparison is valid.
#!/usr/local/bin/perl -w
use List::Util qw(shuffle);
use Benchmark qw
all);
for (1..100_000){
$list[$_] = $_;
$hash{$_} = $_;
}
cmpthese(-3, {
'shuffle' => sub { @aleat=shuffle(@list); },
'newhash' => sub { @aleat=values(%hash); },
});
timethese(-3, {
'shuffle' => sub { @aleat=shuffle(@list); },
'newhash' => sub { @aleat=values(%hash); },
});
__END__
a simple hash could substitute the shuffle operations, but I'm not sure
if the comparison is valid.
#!/usr/local/bin/perl -w
use List::Util qw(shuffle);
use Benchmark qw
for (1..100_000){
$list[$_] = $_;
$hash{$_} = $_;
}
cmpthese(-3, {
'shuffle' => sub { @aleat=shuffle(@list); },
'newhash' => sub { @aleat=values(%hash); },
});
timethese(-3, {
'shuffle' => sub { @aleat=shuffle(@list); },
'newhash' => sub { @aleat=values(%hash); },
});
__END__