Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Sorting blocks and efficiency (in Re to Re: Algorithm::Treap)

by bart (Canon)
on Sep 08, 2003 at 09:23 UTC ( #289724=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
      @sorted = sort { $a <=> $b } @list;
    
  2. or download this
    #!/usr/bin/perl -w
    use strict;
    ...
        reversed_numerical => sub { @sorted = sort { $b <=> $a } @unsorted
    + },
        messed_up=> sub { @sorted = sort { my $cmp = $a <=> $b; $cmp } @un
    +sorted },
    });
    
  3. or download this
    Benchmark: running messed_up, native, numerical, reversed_numerical, r
    +eversed_string, string, each for at least 3 CPU seconds...
     messed_up:  3 wallclock secs ( 3.29 usr +  0.00 sys =  3.29 CPU) @ 75
    +.99/s (n=250)
    ...
    reversed_numerical:  2 wallclock secs ( 3.13 usr +  0.00 sys =  3.13 C
    +PU) @ 379.87/s (n=1189)
    reversed_string:  4 wallclock secs ( 3.62 usr +  0.00 sys =  3.62 CPU)
    + @ 239.78/s (n=868)
        string:  3 wallclock secs ( 3.24 usr +  0.00 sys =  3.24 CPU) @ 22
    +6.54/s (n=734)
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (17)
As of 2015-07-06 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (83 votes), past polls