Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Wasting time thinking about wasted time

by Aristotle (Chancellor)
on Sep 26, 2004 at 17:14 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://393979]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-19 10:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found