Author Topic: The correct script execution speed range?  (Read 376 times)

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
The correct script execution speed range?
« on: October 25, 2011, 09:01:36 pm »


               Hi,

While profiling a near optimized script, what could be considered a correct execution speed, knowing that the given script is called fairly often, as is the case with loot or creature spawners?

For example, testing a custom creature spawner, called in the OnEnter event of any area, the profiler reports:
area_onenter  83ms  210 calls(because of a recursive DelayCommand).

Is this acceptable? Of course the faster the better, but I guess there is a range of "comfort"?

Thanks!

Kato 
               
               

               


                     Modifié par Kato_Yang, 25 octobre 2011 - 08:32 .
                     
                  


            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
The correct script execution speed range?
« Reply #1 on: October 25, 2011, 09:44:10 pm »


               83ms = 0.083s

Once a player has loaded an area (and the scripts fire) just the fadeout from the loading screen takes over twenty times as long. Plus, PCs dont enter areas THAT often, unless you have a really, really populated server. And there is no "correct" execution time. Scripts takes exactly long to execute as they should, and if your script is made with some thougth on your loops, it won't take long enough to execute to cause concern. (If your loops are fine and your execution time is very long, you either have 10k lines of code or something is very, very wrong)

Performance seems to be something some are very worried about here, but really, the most important thing is your scripts are easy to work with and to understand, especially if someone other then you will work with them later. The only time you really should focus on performance is when the script is actually going to fire everywhere and all the time, like a global OnHit property on all PCs and NPCs for custom damage calculation or something nuts like that.
               
               

               


                     Modifié par Xardex, 25 octobre 2011 - 08:49 .
                     
                  


            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
The correct script execution speed range?
« Reply #2 on: October 25, 2011, 10:03:22 pm »


               Well maybe I should have mentioned that the numbers I posted were taken from the profiler's log after a short testing session, sorry. The high OnEnter call number comes from the fact that the script itself calls a recursive function from an include file. Anyway, thanks for these words of advice, Xardex. '<img'>

Kato
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
The correct script execution speed range?
« Reply #3 on: October 25, 2011, 11:36:57 pm »


               

Xardex wrote...

Performance seems to be something some are very worried about here, but really, the most important thing is your scripts are easy to work with and to understand, especially if someone other then you will work with them later. The only time you really should focus on performance is when the script is actually going to fire everywhere and all the time, like a global OnHit property on all PCs and NPCs for custom damage calculation or something nuts like that.

well said

I would add that if you use profiler you can probably see the performance of the monster AI. Everyone there is too obsesed with the performance of their script but if they would know how AI work, how much performance it consumes they would not worried anymore.
               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
The correct script execution speed range?
« Reply #4 on: October 26, 2011, 06:25:38 pm »


               Thanks gentlemen, one learns something new everyday. '<img'>

Kato