Quick Speed Fact

Nestharus

o-o
Reaction score
84
I didn't post the benchmark code because each benchmark had the 100 lines of variables in it, lol...

Let's just say I had to get creative with benchmarking declarations : P.

Oh yea, and I put into spoilers as you requested but.... well, look at post 1 o-o... are spoilers dead?

SPOILER-
hi

yup
 

Jesus4Lyf

Good Idea™
Reaction score
397
Really it is just this kind of stuff that I think is important:
* Setting a local variable vs setting a global variable with a precondition: 100 locals declared and 1 global.
Global is 30% to 60% faster

* Setting a local variable vs setting a global variable with a precondition: 1 locals declared and 100 globals.
Global is 75% faster ???
I mean, maybe the order in which the globals are declared even matters, who knows (ie. use global #1 vs global #100).

That's the reason I don't say these things are x% faster than eachother.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
How is it that the more globals you declare, the faster they are..

Or maybe it is that the more globals you declare, the slower are locals ?
Did you print the values, instead of the ratio between the different times ?
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
So in fact jass2 was made by some magicians o_O.
It could explain some lame bugs xD
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
And why exactly should I let this change my coding style? For unnoticeable "preformance gains"?
 

Azlier

Old World Ghost
Reaction score
461
Doesn't mean you should change your old code. Just keep this in mind when writing new code.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Nah it's all silly.

The point is, are you gonna spam local declarations to circumstancially increase the speed of something? ...

My point with having Nestharus do those tests was understanding that coding optimisations at this level in JASS is not practical. And that these speed things are not "facts", they vary like the wind.

But I generally find globals faster than locals...
 

Azlier

Old World Ghost
Reaction score
461
>optimisations at this level in JASS is not practical.

You know I don't care about practicality.
 

Jesus4Lyf

Good Idea™
Reaction score
397
But facts are kind of tricky... Hey check out this, it's Ricky.

If this gets useful it will get stored somewhere. :nuts:

>You know I don't care about practicality.
Neither, I suppose I meant it isn't possible to really optimise at this level. I mean, the freaks use globals already, right? We knew that well before this thread.

What could work is a tutorial on how to optimise at stupid levels. Feel free to write that with benchmark proofs and stuff. Not saying it will get approved necessarily, but it's better than sticking a thread like this.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Wait ...
Finally i can use the StopWatch natives now

I got about the same speed, with this test code,as i thought, and not 33% of difference :
JASS:
scope Benchmark initializer init

private function Actions takes nothing returns nothing
    local integer watch1
    local integer watch2
    local integer loop1 = 10000
    local integer loop2 = 10000
    local real result1 = 0
    local real result2 = 0
    local player p

    set watch2 = StopWatchCreate()
    loop
        set p = Player(0)
        exitwhen loop2 == 0
        set loop2 = loop2 - 1
    endloop
    set result2 = StopWatchMark(watch2)
    call StopWatchDestroy(watch2)
    call TriggerSleepAction(0)
    
        set watch1 = StopWatchCreate()
    loop
        set p = GetPlayer(0)
        exitwhen loop1 == 0
        set loop1 = loop1 - 1
    endloop
    set result1 = StopWatchMark(watch1)
    call StopWatchDestroy(watch1)
    
    call BJDebugMsg("GetPlayer: " + R2S(result1 * 10))
    call BJDebugMsg("Player: " + R2S(result2 * 10))
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(trig,Player(0))
    call TriggerAddAction(trig,function Actions)
endfunction

endscope


Maybe ExecuteFunc speed is something random you should really avoid using it for benchmarks.
I don't trust anymore in any of your benchmark.
 

Nestharus

o-o
Reaction score
84
Good job at being just so darn accurate and having such great results compared to mine. I guess me, jesus4lyf, and all of the other people who have ever benchmarked before are just uber newbz compared to ur plain awesomeness.

Oh wait, I take that back-
JASS:
    local integer watch1
    local integer watch2
    local integer loop1 = 10000
    local integer loop2 = 10000
    local real result1 = 0
    local real result2 = 0
    local player p


JASS:
 set watch2 = StopWatchCreate()
    loop
        set p = Player(0)
        exitwhen loop2 == 0
        set loop2 = loop2 - 1
    endloop
    set result2 = StopWatchMark(watch2)


JASS:
    local trigger trig = CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(trig,Player(0))
    call TriggerAddAction(trig,function Actions)




And this one has to be my favorite
JASS:
call BJDebugMsg("GetPlayer: " + R2S(result1 * 10))



Yea, it's just no wonder your results are just so darn accurate, especially with that conversion man. You are just too 1337 for me.



In all seriousness, I know I'm laying it on thick, but at least learn the natives before you start benchmarking kk ^_-.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Good job at being just so darn accurate and having such great results compared to mine. I guess me, jesus4lyf, and all of the other people who have ever benchmarked before are just uber newbz compared to ur plain awesomeness.

Oh wait, I take that back-
JASS:

    local integer watch1
    local integer watch2
    local integer loop1 = 10000
    local integer loop2 = 10000
    local real result1 = 0
    local real result2 = 0
    local player p


JASS:

 set watch2 = StopWatchCreate()
    loop
        set p = Player(0)
        exitwhen loop2 == 0
        set loop2 = loop2 - 1
    endloop
    set result2 = StopWatchMark(watch2)


JASS:

    local trigger trig = CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(trig,Player(0))
    call TriggerAddAction(trig,function Actions)




And this one has to be my favorite
JASS:

call BJDebugMsg("GetPlayer: " + R2S(result1 * 10))



Yea, it's just no wonder your results are just so darn accurate, especially with that conversion man. You are just too 1337 for me.



In all seriousness, I know I'm laying it on thick, but at least learn the natives before you start benchmarking kk ^_-.
@Troll
Whilst I have no idea what's wrong with Nestharus, I'd consider this modification:
JASS:
    loop
        set p = Player(0)
        exitwhen loop2 == 0
        set loop2 = loop2 - 1
    endloop

-->
JASS:
    loop
        set p = Player(0) // 1
        set p = Player(0) // 2
        set p = Player(0) // 3
        set p = Player(0) // 4
        set p = Player(0) // 5
        set p = Player(0) // 6
        set p = Player(0) // 7
        set p = Player(0) // 8
        set p = Player(0) // 9
        set p = Player(0) // 10
        exitwhen loop2 == 0
        set loop2 = loop2 - 1
    endloop

Change 10,000 to 1,000. Etc. It diminishes the exitwhen comparison and set loop2=loop2-1. Which, when you're dealing with this level of stuff, matters a lot. :thup:

Let us know what sort of results you get then, thanks for benchmarking.
 

Nestharus

o-o
Reaction score
84
Multiple local variables are going to make it not accurate : 9.


TriggerSleepAction does strange things to threads : 9


Not setting up a stopwatch, letting it run for a second or two, and then destroying it before using them isn't god : 9


Using R2S means your results are botched anyways. You need to use R2SW (what I meant by learn the natives).


And there are a few other things ^_^


For me, because I used ExecuteFunc I had to initialize the strings table by setting strings before hand =).


Also, another thing is that my results are apparently totally wrong according to Troll-Brain, even though ones that were testing what's already been tested fell in line with the results others got, unless my results are magical and some are accurate and some are wrong all on the same thing? Or everyone else is wrong and Troll-Brain is right.

Those were the points i was tying to make =).
 

Jesus4Lyf

Good Idea™
Reaction score
397
>Multiple local variables are going to make it not accurate
Or not having multiple local variables is going to make it not accurate (more likely).

>TriggerSleepAction does strange things to threads
It resets threads.

>Not setting up a stopwatch, letting it run for a second or two, and then destroying it before using them isn't god
What?

>Using R2S means your results are botched anyways. You need to use R2SW (what I meant by learn the natives).
Whatever. R2S is fine for 3 decimal places.

>For me, because I used ExecuteFunc I had to initialize the strings table by setting strings before hand =).
The strings table already has function names in it, if I recall correctly. And I wouldnt not expect [LJASS]ExecuteFunc[/LJASS] to have a constant execution time - it probably performs a stringhash.

>ones that were testing what's already been tested fell in line with the results others got
Disagreed.

>Those were the points i was tying to make =).
And you failed to make them, instead sounding like an arrogant idiot. (I think you're better than that.)
 

Nestharus

o-o
Reaction score
84
Made them initially, but edited my post =). I had also explained why I used ExecuteFunc() over TriggerExecute or TriggerEvaluate (maintainability reasons o-o).

The thing is Jesus4Lyf, in my first test comparing Player() to an array, I got the native as being faster than the array, that is until I set a string before hand. After I did that, I got 33% difference of array being faster, which made more sense.


But are actually telling me that code on one thread runs slower than code on another thread? That would be the only way my results would be bad...

And if you are telling me that, I ask you how that is possible. I'm not saying one thread starts up faster than another thread, I'm saying run code. I do the stopwatch things on the threads being run, not in the initial thread, so ExecuteFunc() shouldn't even matter.

I'm asking you how that makes sense =)
 

Jesus4Lyf

Good Idea™
Reaction score
397
>I'm asking you how that makes sense =)
Nothing in JASS makes sense. You're telling me that initialising the string table completely changed your results? But all you did was move that string creation from one place outside the stopwatch mark to another place outside the stopwatch mark...

As far as I care, none of you know a single thing about benchmarking until you do this:
JASS:
    loop
        set p = Player(0)
        exitwhen loop2 == 0
        set loop2 = loop2 - 1
    endloop

-->
JASS:
    loop
        set p = Player(0) // 1
        set p = Player(0) // 2
        set p = Player(0) // 3
        set p = Player(0) // 4
        set p = Player(0) // 5
        set p = Player(0) // 6
        set p = Player(0) // 7
        set p = Player(0) // 8
        set p = Player(0) // 9
        set p = Player(0) // 10
        exitwhen loop2 == 0
        set loop2 = loop2 - 1
    endloop
Because the operations you're performing are faster than
JASS:
        exitwhen loop2 == 0
        set loop2 = loop2 - 1

!!

Hence why I said this thread is useless.
Hence another reason your results are unreliable.
Hence why I don't give a crayon about any of this.

You realise that if the speed of this depends completely on the number of locals declared at the time then it is all worthless, regardless what you can prove or demonstrate...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top