|Keep It Simple, Stupid|
Re^6: Question about curious performance of if...elsif blockby markseger (Beadle)
|on Jan 16, 2012 at 20:18 UTC||Need Help??|
> No. Because it would not run here. ahh, so I guess you're not running linux.
no problems. here's a run with the subroutine call commented out:
now with the call executing BUT the return statement executing first thing in the subroutine:
so clearly the overhead in calling the subroutine 1M times is about 5-1/2 seconds. Now I'll comment out the early return in the subroutine in the subroutine and run it again:
This says to me the if...elsif... takes about 6 seconds and I can't fathom why! Could there be some weird interaction going on between perl/linux and the /proc filesystem?
As I said in my base note I'm not an innards kind of a guy but it feels like something that is not going to show up in every perl script. Rather if feels like there is some kind of weird interraction.
and speaking of environment this is rhel5.3 and perl 5.8.8. I just tried the code again on rhel6.2 in a VM with perl 5.10, and the differences between the last 2 runs are:
so in this case both the subroutine calls and the if...elsif... block are only taking a little over 2 seconds each. This says to me there is something more efficient going on with 5.10.
Perhaps this is less of a big deal as 2 extra seconds is getting less of a concern, but I still an curious about what exactly is going on.