Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: About List::Util's pure Perl shuffle()

by ikegami (Pope)
on Jul 11, 2007 at 17:47 UTC ( #626057=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub ikegami (@) {
        my @a=@_;
    ...
        my $x;
        map +( $n=rand($i--), $x=$a[$n], $a[$n]=$a[$i] )[1], @a
    }
    
  2. or download this
               Rate    naive listutil   runrig broweruk  ikegami
    naive     636/s       --      -6%     -19%     -26%     -37%
    ...
    runrig    785/s      23%      16%       --      -9%     -22%
    broweruk  859/s      35%      27%       9%       --     -15%
    ikegami  1010/s      59%      50%      29%      18%       --
    
  3. or download this
    our @data = map { 'x' x 1000 } 1..1000;
    cmpthese -3, { map { $_ => "$_ \@data" } qw/naive listutil broweruk ru
    +nrig ikegami/ };
    
  4. or download this
              Rate   runrig    naive  ikegami listutil broweruk
    runrig   118/s       --     -10%     -40%     -43%     -86%
    ...
    ikegami  197/s      68%      51%       --      -5%     -77%
    listutil 207/s      76%      58%       5%       --     -76%
    broweruk 860/s     632%     558%     336%     315%       --
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://626057]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2014-12-28 03:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (178 votes), past polls