in reply to Re^8: Some code optimization
in thread Some code optimization

You are comparing "running the logic of the function in-line" vs. "calling a function that does not execute the logic". That's not the comparison that matters. Comment out the "return" at the top of the function in the latter version, and the timing shows the function call to be more expensive than the inline code.

Another minor detail: in your inline version, you do two hash lookups for the value of  $zone_o->{_chromosome_length} whereas the function call version does only one lookup. If you change the inline version to assign that value to a "my" variable, and use that variable twice (just like it was used twice in the function call), you'll see a reduction of a few sec -- i.e. the improvement over the function call will be more evident.

Now, get back to the part that really matters.

Replies are listed 'Best First'.
Re^10: Some code optimization
by roibrodo (Sexton) on Jun 18, 2010 at 12:12 UTC
    Thanks. Indeed I forgot to omit the return. I will now go on to follow the reco's regarding the second part and look forward to coming back here updating you.

    I must comment that I am still surprised that such a simple function/piece of inline code takes so much time to execute. I never looked at this level of benchmarking, so I guess I had mistaken expectations.