performance gain by using subroutine prototypes? 
Author Message
 performance gain by using subroutine prototypes?

hello all,

is there any performance boost when subroutines are declared with prototypes?

thanks in advance,

--bill



Tue, 31 Aug 2004 13:28:49 GMT  
 performance gain by using subroutine prototypes?

Quote:
> hello all,

> is there any performance boost when subroutines are declared with prototypes?

> thanks in advance,

> --bill

I don't believe so.

CJ

----------------------------------------------------------------------------
Year 2000 never bothered me.
It's year 65536 that I'm worried about
----------------------------------------------------------------------------
H4x0R : I'm way cooler than you! I got 40 scrypts that can kill yer machine
sysop : Heh! Yeah right!
w33n3r: Yeah. I can nail you from here man ... gimme your ip and you're toast!
l4m3rz: Yeah .. we rock .. we're gonna fry your machine
sysop : Ok, I dare ya ... My ip is 127.0.0.1
H4x0R : ##Disconnected##
w33n3r: ##Disconnected##
l4m3rz: ##Disconnected##



Tue, 31 Aug 2004 22:11:44 GMT  
 performance gain by using subroutine prototypes?

Quote:



>> hello all,

>> is there any performance boost when subroutines are declared with prototypes?

>> thanks in advance,

>> --bill

> I don't believe so.

There is a special case where a prototype allows perl to avoid doing the call
at run time e.g.

#!/usr/bin/env perl

sub one {
    return 1;

Quote:
}

sub two () {
    return 2;

Quote:
}

use constant three => 3;

use Benchmark;

timethese (10_000_000, {
    no_call => '$x = 1;',
    one     => '$x = one;',
    two     => '$x = two;',
    three   => '$x = three;',

Quote:
} );

See the perlsub documentation's Constant Functions section for an explanation.

The Prototypes section of the same document describes some of the motivations
for and uses of prototypes in Perl ... they may not be what the OP thinks
they are.

Hope this helps,

Mike

--

http://www.stok.co.uk/~mike/       | GPG PGP Key      1024D/059913DA

http://www.starnix.com/            |                  75D2 9EC4 C1C0 0599 13DA



Tue, 31 Aug 2004 22:39:21 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using 'require' and performance gains

2. PERLFUNC: prototype - get the prototype (if any) of a subroutine

3. PERLFUNC: prototype - get the prototype (if any) of a subroutine

4. Subroutine prototype syntax for passing typeglob?

5. What is a correct prototype for a subroutine w/o arguments

6. subroutine prototypes and require question

7. declarating subroutine prototypes

8. Subroutine prototype puzzlement

9. Subroutine prototypes and overloading

10. Subroutine Prototypes, Hard References and Maintainable Code: take 2

11. Subroutine Prototypes, Hard References and Maintainable Code

12. Subroutines:: Return Type Vs Performance

 

 
Powered by phpBB® Forum Software