Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Subroutine overhead in Perl

by TedYoung (Deacon)
on Nov 06, 2007 at 17:56 UTC ( [id://649290]=note: print w/replies, xml ) Need Help??


in reply to Subroutine overhead in Perl

Well, I think we will need the java code to try and identify any obvious differences. My fist guess would be that the java version may have used tail recursion extensively. That can be a huge benefit because it nearly eliminates the overhead of a subroutine call all together. Even if he didn't there are some really cool hotspot optimizations that JDKjava 1.6 can do. For instance, the equivalent of the grid_check method would likely be compiled down to machine code and run natively during runtime, where as the perl version would always be interpreted. And again, depending on how the java version was written, many of his method calls could have been inlined.

Update: I remember hearing quite often that perl sub calls were rather slow (aside from no tail recursion support), but I cannot remember the details as to why they may be slower (it is possible that this is no longer an issue either). Hopefully someone better informed will either dispel or clarify this.

Ted Young

($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)

Replies are listed 'Best First'.
Re^2: Subroutine overhead in Perl
by enemyofthestate (Monk) on Nov 06, 2007 at 19:29 UTC
Re^2: Subroutine overhead in Perl
by enemyofthestate (Monk) on Nov 06, 2007 at 18:25 UTC

    Tail recursion was one of the thing we all talked about whikle working on the problem. If I could have made it tail recursive I could convert it to a simple iteration.

    I'll email the winner and ask for his source.

    --
    Stephen

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-25 10:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found