in reply to Re: Re: Performance Tuning: Searching Long-Sequence Permutations
in thread Performance Tuning: Searching Long-Sequence Permutations

Does the length builtin get called as a function or is it translated (or optimised) to a "direct reference" to the target string length property at compile time?


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


  • Comment on Re: Re: Re: Performance Tuning: Searching Long-Sequence Permutations

Replies are listed 'Best First'.
Re: Re: Re: Re: Performance Tuning: Searching Long-Sequence Permutations
by diotalevi (Canon) on Jun 27, 2003 at 11:37 UTC

    It fetches the length value out of the passed-in string. When given a non-string, it is first converted to a string per normal perl. This is of course, a runtime operation.

      So there is some computation involved then:)

      In fact, I wouldn't mind betting that C could compute the length of several dozen strings in the time Perl takes to build the stack frame, call length, obtain the information and return it to the caller.

      Though how many (dozens) would depend upon how long the strings are:)


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


        For this particular op I don't *see* it messing with the stack and it does the one op in a register. I imagine its about as fast as a defined() or similar call.