Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: $foo = "Foo::Bar"; $foo->new() works?

by gaal (Parson)
on Jan 23, 2005 at 16:32 UTC ( #424412=note: print w/ replies, xml ) Need Help??


in reply to Re: $foo = "Foo::Bar"; $foo->new() works?
in thread $foo = "Foo::Bar"; $foo->new() works?

It even turns out that there is no speed difference. (I expected *some* advantage to the inline string, because there'd be an extra indirection. But it's lost to the method call overhead.)

use Benchmark; package Bar; sub new {}; package main; my $obj; my $class = "Bar"; # "our" *is* slower, though. timethese -1, { bareword => sub { $x = Bar->new() }, var => sub { $x = $class->new() }, }; ######################################### Benchmark: running bareword, var for at least 1 CPU seconds... bareword: 1 wallclock secs ( 1.06 usr + 0.00 sys = 1.06 CPU) @ 59 +0160.38/s (n=625570) var: 1 wallclock secs ( 1.06 usr + 0.00 sys = 1.06 CPU) @ 59 +0160.38/s (n=625570)


Comment on Re^2: $foo = "Foo::Bar"; $foo->new() works?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (20)
As of 2015-07-31 16:19 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 (279 votes), past polls