Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Is this comparison valid?

Reply
Thread Tools

Is this comparison valid?

 
 
gamo@telecable.es
Guest
Posts: n/a
 
      06-09-2013

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__


 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      06-09-2013
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
>I have installed 5.18, and think that if hashes are randomized,


Where did you read that hashes are randomized? AFAIK the sequence is
deterministic although of no practical value (and therefore may appear
to be randomized to the casual observer).

jue
 
Reply With Quote
 
 
 
 
gamo@telecable.es
Guest
Posts: n/a
 
      06-09-2013
Where did you read that hashes are randomized? AFAIK the sequence is
deterministic although of no practical value (and therefore may appear
to be randomized to the casual observer).

jue
-------------------

in perldelta

it says:

Hash randomization

The seed used by Perl's hash function is now random. This means that
the order which keys/values will be returned from functions like
"keys()", "values()", and "each()" will differ from run to run.


 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      06-09-2013
(E-Mail Removed) wrote:
>Where did you read that hashes are randomized? AFAIK the sequence is
>deterministic although of no practical value (and therefore may appear
>to be randomized to the casual observer).
>
>jue
>-------------------
>
>in perldelta
>
>it says:
>
> Hash randomization
>
> The seed used by Perl's hash function is now random. This means that
> the order which keys/values will be returned from functions like
> "keys()", "values()", and "each()" will differ from run to run.



Interesting.

Thanks

jue
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Who can explain this bug? mathog C Programming 57 06-11-2013 10:09 PM
How do I encode and decode this data to write to a file? cl@isbd.net Python 11 05-01-2013 11:36 PM
Why does this incorrect CRTP static_cast compile? kfrank29.c@gmail.com C++ 2 04-25-2013 01:38 PM
This looks like a Perl bug George Mpouras Perl Misc 18 04-21-2013 11:56 PM
Really throwing this out there - does anyone have a copy of my oldDancer web browser? steven.miale@gmail.com Python 1 04-10-2013 03:32 PM



Advertisments