0 Replies Latest reply on May 26, 2006 6:04 PM by Paulygon

    Efficient Lingo Tips

    Paulygon
      Hi all. This may be old news to the smart people out there, but a couple of recent experiments surprised me, and I figured it wouldn't hurt to share my results. I made a simple movie script handler that looks like this:

      on SpeedTest
      theTime = the milliseconds
      repeat with i = 1 to 50000
      (do something)
      end repeat
      put the milliseconds - theTime
      end

      The thing I wasn't expecting is that pre-defining a variable as a model reference is amazingly faster than not doing so. Let me illustrate:

      on SpeedTest
      theTime = the milliseconds
      theModel = member("3d").model("some model")
      repeat with i = 1 to 50000
      this = theModel.getWorldTransform()
      end repeat
      put the milliseconds - theTime
      end

      When I use member("3d").model("some model") within the repeat loop it gets VERY slow. I just didn't see that coming. Further, using model("some model") is around twice as fast as using the model's index number like this: model[2]

      Finally, I was just winging this, so if there's something fishy about my methodology, or something isn't adding up, let me know. In short, I highly recomend trying out something like this. You might be surprised how much you can improve your frame rate with a few simple changes.