Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://393979]
help
Chatterbox?
[MidLifeXis]: Leveraging prove to do data validation on an ETL process. What am I smoking??? :-)

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2016-12-07 19:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (131 votes). Check out past polls.