Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 rifling through the Monastery: (11)
As of 2014-09-19 23:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (151 votes), past polls