Jump to content

Time how long each of my scripts is taking to run?


BFG99

Recommended Posts

I recently released a couple of mods that have to constantly monitor the player and nearby NPCs. (The mod unequips broken armor and replaces it with the best clothing in inventory. It also constantly changes the strength of magically enchanted armor or clothing according to the condition/health of the equipment.)

 

Because it has to work in this way, I'd like to be able to "time" the scripts to see how long they take to execute. That would help me determine the most efficient approaches. Does anyone have any idea how to set up a script so it can time itself?

Link to comment
Share on other sites

The default is that Begin GameMode scripts run every five seconds. This is complicated by the fact that some computers lag and five seconds might not be five seconds. Some commands don't work or don't work reliably in Begin GameMode blocks and this muddies the waters further. There is also the question of whether you came in at the beginning of a cycle, the middle, or the end. So after the triggers trip, the code could execute anywhere between 0.01 and 5.0 seconds afterward assuming standard amount of lag.
Link to comment
Share on other sites

Thanks, David. I don't like using GameMode for some of the reasons you've described, but for a game effect change mod like this I don't know any other effective way.

The good news is that I did figure out a way to time how long my scripts take to execute using GetSecondsPassed. When I compared that to the baseline (i.e. my mod replaced by a single script that ONLY reports the time passed), I was able to determine all my scripts combined need less than 1/100th of a second to run, at least on my machine. Not too bad given the complexity. :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...