Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Subroutine overhead in Perl

by Joost (Canon)
on Nov 06, 2007 at 18:19 UTC ( [id://649303]=note: print w/replies, xml ) Need Help??


in reply to Subroutine overhead in Perl

You have a bunch of constructs in grid_check() like this:
# For each possible value of the target -- # remember to invert the sense of the search foreach $val (grep{!$list[$_]}1..9) { $grid[$cntr] = $val; grid_check(); }
Where it looks like @list (and a whole lot more stuff) is created by each call to grid_check(). Generally, you want recursive functions to pass arguments. (I can't even see if that code would *ever* stop calling itself since I can't see what the stop conditions are).

update: just to address your question: perl's subroutine calls aren't exactly the quickest and I wouldn't be surprised if they'd be a lot (maybe even 10 times, if the Java VM can do some good hot spot optimization) slower than Java's, but even considering that, it seems obvious to me that what's really causing a significant slowness is not the function call overhead, so it's probably your algorithm.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-03-29 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found