• 🏆 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!

[Trigger] Wait vs PolledWait - Test

Status
Not open for further replies.
Level 11
Joined
Jul 12, 2005
Messages
764
I made an experiment on this allways-up-to-date quaestion:
Which one is better, simple Wait, or PolledWait ('Wait game-time seconds' in GUI)?

Includes 4 triggers, 2 in GUI, and 2 in JASS (just for curiousity).
The triggers start a timer, and then it displays the elapsed time of the timer after a defined time.
The first trigger uses simple Wait, the second uses PolledWait.

There are 4 commands:
-w #
-pw #
-jw #
-jpw #

Test it, and post your opinions and notices. I got interesting results.

Recommended to test these wait-times:
0, 0.1, 1
 

Attachments

  • WaitTest.w3x
    17.9 KB · Views: 92
Level 6
Joined
Mar 2, 2006
Messages
306
paskovich said:
I got interesting results
but you don't want to share them?
PurplePoot said:
PW isn't accurate. That's a misconception. It's more accurate, but can be almost as bad, especially with small waits.
let's not mix accuracy and domains; polled wait works for numbers between 0.27sec and +oo. so and argument of 0.05sec isn't an example of its inaccuracy; it is and out-of-dommain number. on the other hand, as far as i know, polledwait is much more accurate for small intervals (0.4-0.8s, for example) than for really long ones (several minutes)...
 
Level 10
Joined
Nov 10, 2004
Messages
351
PW does though use TSA if the wait time is more than 2 secs.
I can't really see why if it is inaccurate as it uses timer(must be the loop then)

Are you sure that TSA can cause desyncs? since many of the simpler GUI maps uses it alot. I think i once heard that TSA does not stop when someone starts to lag.
 
Level 5
Joined
Feb 16, 2006
Messages
151
JASS:
If (GetLocalPlayer == p) then
   call TriggerSleepAction(1.00)
endif
There, this causes a desync, but who the hell would do that.
PolledWait is inaccurate.
JASS:
function PolledWait takes real duration returns nothing
    local timer t
    local real  timeRemaining

    if (duration > 0) then
        set t = CreateTimer()
        call TimerStart(t, duration, false, null)
        loop
            set timeRemaining = TimerGetRemaining(t)
            exitwhen timeRemaining <= 0

            // If we have a bit of time left, skip past 10% of the remaining
            // duration instead of checking every interval, to minimize the
            // polling on long waits.
            if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then
                call TriggerSleepAction(0.1 * timeRemaining)
            else
                call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
            endif
        endloop
        call DestroyTimer(t)
    endif
endfunction
Although it uses timer, at the end, it still uses TriggerSleepAction.
(And it leaks a t variable D: ).
I still recommand using TriggerSleepAction, reason:
Either you want 100% accurancy, which means you must use Timers, or you don't care about accurancy, then you use TriggerSleepAction.
PolledWait is a in between, which means it's useless.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
In GUI it is better because if you wait 5 seconds in multiplayer you get an inaccuracy of 25% (longer) or more if you are playing with people far away and you have high ping.

Wait is the least buggy and it DOES stop with lag if I am not wrong while polled wait does not.

Occasionaly a polledwait CAN bug and badly, causing a time of 900 seconds to be 1.5 seconds (happened twice in DBZ tribute ultra to me) but thats a game bug and has only ever happened to me in 3 games out of over 3000 I have played (1/1000 chace or lower) so do not worry.

The main trouble with wait is "noobs" use it and test their map in single player and it works fine while when they go to multiplayer, suddenly timers are messed up. An example is in a zombie shooter RPG I played, TK gave you a 1 min jail sentance but it actually lasted nearly 2-3 game time minutes. Other maps also have the trouble with timers finishing before the wait does and thus having to wait a long time. Polledwait, unlike wait, becomes less ACCURATE but the DURATION does not change since it uses timers.

Lets say we have 2 functions with 2 waits of the same duration of 120 seconds, one is polled the other TSA.
Lets imagin the waitdelay is 25%
With the TSA it will last 150 seconds (half a minute more which can really annoy)
With PW it will last between 120-121.25 seconds (the wait could be anything between that time) which at worst will be 19% more accurate.
As the waitdelay would be increased, the range will increase but minimally compared to the inaccuracy the non polled wait has.

Thus only with durations of under 0.1 seconds is it inaccurate and using normal TSA (trigger sleep action) would be better.

Polledwait becomes inaccurate alos if you were to get a insane dely factor of over 1000% which is unlightly and it would still beat TSA a lot.

So unless you are using times of less than 1 second seconds polledwait should always be used. If the time is less than 1 second use normal wait since the inacuracy is minimal
 
Status
Not open for further replies.
Top