in reply to Subroutine overhead in Perl
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).# 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(); }
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.
|
|---|