• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[vJASS] Timer Utils and Timer Tools

Status
Not open for further replies.
I felt the need to make a double post because of some very mind-blowing results I got while benchmarking this against TimerUtils.

I used this spell:
http://www.hiveworkshop.com/forums/spells-569/epicenter-v2-1-0-0-a-204120/

During the tests, I removed the special effect to maximize FPS.

Code:
10 casts:
    TimerUtils: 2 FPS Drop
    TimerTools: 1 FPS Drop
20 casts:
    TimerUtils: 9-11 FPS Drop
    TimerTools: 2-4 FPS Drop
60 casts:
    TimerUtils: 24-28 FPS Drop
    TimerTools: 6-8 FPS Drop
150 casts:
    TimerUtils: 50-52 FPS Drop
    TimerTools: 12-15 FPS Drop

Ultimate stress test:

With 1000 casts and special effects enabled, TimerUtils died.
TimerTools on the other hand was able to run at 5 FPS.

Yes, with 2500 special effects per second, TimerTools was incredibly reliable.

Good day to you haters.

I hope this answers your question.
They're used for pretty much the same thing.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
@Mag :

http://www.wc3c.net/showpost.php?p=1134022&postcount=20

Also did you optimized the tested code with a script optimizer before the benchmark ?

Now, honestly i can't figure a way where i would have many timers to merge together, or even have many timers running at the same time.
For me it's TimerUtils way (my own personal implementation) + several unique periodic timers such as 1/32 s.
 
The difference is that TimerUtils recycles timers while TimerTools merges timers. They both work to save timer handles and serve for data storage. For a description of TimerTools:
Timer tools timers use a special merging algorithm. When two timers merge, they both expire on the same timer. The first tick accuracy is based on the size of the timer's timeout.
The larger the timeout, the more inaccurate the first tick can be. The tick only becomes inaccurate if it merges with another timer.

TimerUtils, on the other hand, just uses simple recycling. For example, if you are done using a timer, it will be recycled and available for use at some other point in time.

They both conserve the timer creation/usage, and both work well. TimerTools specializes in periodic loops, so you can use it for that. I recommend TimerUtils for everything else. However, you can really use either one. In the end, it comes down to personal preference. If you are more comfortable using TimerUtils, then use that. If you are more comfortable using TimerTools, then use that. The speed difference will not be noticeable in-game under realistic circumstances.
 
The point is basically that some actions performed by the game take time for the system to execute. One such thing is creating and destroying timers, and that is why you can take some load off the system by only creating the timers once and then put them in a stack once you are done with them, so that next time you want a timer, you can just pick an already existing one from the stack instead of creating a new one. This is all done automatically since you just replace CreateTimer() and DestroyTimer() with NewTImer() and ReleaseTimer().

Another such thing that takes time for the system happens when the timers expire. I don't know much about nestharius system, but from my understanding it merges timers together to a single timer so that it only has to expire once.

Generally i would say, that as long as you doesn't have any hardcore systems in your map, you would propably be better off using TimerUtils, since it is so easy to use and implement.
 
If you have /lots/ of timers running in your map or if you're experiencing heavy lag, Nestharus' TimerTools /will/ cause the FPS to rise by at least 10.

-Kobas- switched from TimerUtils to TimerTools and Damage/AIDS to DamageEvent/UnitIndexer and now, Shadows of the Past runs at 40FPS on weak computers.

If you don't have lag, keep using TimerUtils because it's incredibly easy to do so.
All you have to do:

call TimerStart(NewTimerEx(anyIntegerYouWantToAttachToTheTimer), TIMER_TIMOUT, IS_IT_PERIOD?, function theFunctionThatWillExecuteWhenItExpires)
or, if you don't need to attach any data to the timer, just replace NewTimerEx(....) with NewTimer()
 
Use whichever you'd like, you won't notice any difference. While T32 and TimerTools are better/more efficient for high frequencies, you can really even use TimerUtils and you won't experience fps drops. (unless, as I said, you have maybe a hundred or so instances running at the same time)

If you do experience fps drops, you can try using a different system, but chances are that it is not the timer system that is causing the problem. Fps drops are normal and are caused by a multitude of things, such as how many objects are being rendered on screen. (more often than not, they are caused by the GPU) For that reason, you should use whatever you are most comfortable with.
 
How do I implement and use it, then ?

Go to this page and copy the text in the hidden field called "Chromatic TimerUtils (patch 1.23b or later):".

Then you create an empty trigger in your map, remove everything from it, and paste the code you copied into it. Name the trigger "TimerUtils" or whatever you want to keep track of it.

And presto! Now all you need to do to use it is to replace all CreateTimer() calls with NewTimer(), and all DestroyTimer() calls with ReleaseTimer(). You can simply use the find/replace function in JNGP.

Oh, and you will need JNGP to use this, if you don't already have it. Download it here and follow all the instructions, you want to download from the alternate link (called "JNGP 5d with JassHelper 0.A.2.B") since that one has the newest version of jasshelper installed by default.
 
Status
Not open for further replies.
Top