[root@poker collectl]# time ./test.pl
real 0m14.464s
user 0m5.089s
sys 0m9.087s
now with the call executing BUT the return statement executing first thing in the subroutine:
[root@poker collectl]# time ./test.pl
real 0m19.508s
user 0m10.461s
sys 0m8.853s
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:
[root@poker collectl]# time ./test.pl
real 0m25.648s
user 0m16.350s
sys 0m9.123s
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:
real 0m7.359s
user 0m2.840s
sys 0m4.481s
real 0m9.782s
user 0m5.082s
sys 0m4.615s
real 0m11.927s
user 0m7.266s
sys 0m4.604s
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.
-mark |