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

Re: Wasting time thinking about wasted time

by Aristotle (Chancellor)
on Sep 26, 2004 at 17:14 UTC ( #393979=note: print w/ replies, xml ) Need Help??


in reply to Wasting time thinking about wasted time

It's a lot longer and wouldn't fit on a slide

I don't see why it has to be. You can level the playing field without any significant difference.

use Benchmark qw( timethese ); my @files = glob "/bin/*"; timethese( -2, { Ordinary => sub { () = sort { -M $a <=> -M $b } @files }, Schwartzian => sub { () = map $_->[0], sort { $a->[1] <=> $b->[1] } map [ $_, -M ], @files; }, }, );

And that's it. Note that I always use sub refs with Benchmark, so the package issues don't even come up. You could assign to an actual array if you don't feel like explaining the () = .. construct, but it wouldn't make an appreciable difference in the code.

Makeshifts last the longest.


Comment on Re: Wasting time thinking about wasted time
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2015-07-05 21:51 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 (68 votes), past polls