- Joined
- Apr 27, 2008
- Messages
- 2,455
I was bored of statements on the fly without any benchmarks provided, and because jass is enough fun for making false assumptions which beat the logic, i decided to make benchmarks.
I use cJass, just because it's the best tool i know for making benchmarks.
You can get it there : http://cjass.xgm.ru/
Because variable and function name length really do matter i will just assume that the code will be correctly optimized (one letter for locals, and two for globals/functions).
1 for locals because 52 combinations is more than enough (a-Z), and two for globals/functions because it seems also fair (52*62 = 3224) , (62 -> a-Z ; 0-9 but not _ )
Also don't take me wrong, i'm not a speed-freak, i'm perfectly aware that most of times script optimization is not needed and even that some (many ?) benchmarks here are quite or more pointless in real cases.
Fps drop test could give different results depending the operating system and the hardware configuration, but i will presume that it is reliable, it's not like we have decent other ways.
But you're welcome to test these codes by yourself and give your results.
Or submit your own tests, but plz give the code and the results together, just giving the result is bullshit.
Oh and btw the title could be pretentious but it's really not, it's just a (bad) pun (X-Files)
So first, here is a cJass template for benchmarks :
locals vs globals in a theoretical scenario (1 declaration/setting + 2 read)
I just realized that this test is a fail because of what i've said above, i keep it because theoretically globals are faster than locals but in a practical case i don't know yet, just because of the number of globals and their name length.
I will do a better one when i will have the appropriate tool for it.
Result : 30 fps for locals and 58 fps for globals (just starting to lost fps, my max is 60 fps)
Conclusion : Since it's only a theoretical use i can't conclude yet
PS : I'm open to all critics, comments and suggestions as long they are constructive.
I use cJass, just because it's the best tool i know for making benchmarks.
You can get it there : http://cjass.xgm.ru/
Because variable and function name length really do matter i will just assume that the code will be correctly optimized (one letter for locals, and two for globals/functions).
1 for locals because 52 combinations is more than enough (a-Z), and two for globals/functions because it seems also fair (52*62 = 3224) , (62 -> a-Z ; 0-9 but not _ )
Also don't take me wrong, i'm not a speed-freak, i'm perfectly aware that most of times script optimization is not needed and even that some (many ?) benchmarks here are quite or more pointless in real cases.
Fps drop test could give different results depending the operating system and the hardware configuration, but i will presume that it is reliable, it's not like we have decent other ways.
But you're welcome to test these codes by yourself and give your results.
Or submit your own tests, but plz give the code and the results together, just giving the result is bullshit.
Oh and btw the title could be pretentious but it's really not, it's just a (bad) pun (X-Files)
So first, here is a cJass template for benchmarks :
JASS:
library Benchmark initializer init
#define private TEST_TO_DO = 1
#define private PERIOD = 0.01
#define private CHECK_LIMITOP = true
/*
TEST_TO_DO -> Attribute unique integers for your tests, then the user has just to edit its value,
to compare your test codes.
PERIOD -> it's the timout of the timer, depends mostly your hardware configuration.
If it lags to much try an higher value, if there isn't enough fps drop, try a lower one.
Just be aware that the min timeout possible for a timer is 0.0001
CHECK_LIMITOP -> Set it to true if you want to ensure that your script doesn't reach the limitop.
When you have checked all your codes (by editing the value of TEST_TO_DO and compiling/running the map),
set it to false to perform the benchmarks.
*/
globals
// put your globals here
endglobals
#if (CHECK_LIMITOP)
private boolean limit_op_reached = true
#endif
nothing T() { // Test function
#if (TEST_TO_DO == 1)
// put your code here
#elseif (TEST_TO_DO == 2)
// put your code here
#else
PauseTimer(GetExpiredTimer()) ; DisplayTimedTextFromPlayer(GetLocalPlayer(),0,0,666,"invalid TEST_TO_DO value, define it with a valid one")
#endif
#if (CHECK_LIMITOP)
limit_op_reached = false
#endif
}
private nothing init() {
#if (CHECK_LIMITOP)
TimerStart(CreateTimer(),0,false,function T) ; TriggerSleepAction(0)
if (limit_op_reached)
DisplayTimedTextFromPlayer(GetLocalPlayer(),0,0,666,"WARNING : limitop reached for your test " + I2S(TEST_TO_DO))
else
DisplayTimedTextFromPlayer(GetLocalPlayer(),0,0,666,"limitop not reached for your test " + I2S(TEST_TO_DO))
endif
#else
TimerStart(CreateTimer(),PERIOD,true,function T)
#endif
}
endlibrary
locals vs globals in a theoretical scenario (1 declaration/setting + 2 read)
I just realized that this test is a fail because of what i've said above, i keep it because theoretically globals are faster than locals but in a practical case i don't know yet, just because of the number of globals and their name length.
I will do a better one when i will have the appropriate tool for it.
JASS:
library Benchmark initializer init {
#define private TEST_TO_DO = 2 // 1 for locals test and 2 for globals test
#define private PERIOD = 0.007 // depends your hardware configuration, if it lags to much try an higher value, if there is not enough fps drop try a lower one, btw the min is 0.0001
globals
#for i (1,5000)
integer J##i
#endfor
endglobals
private nothing Test() {
integer x
#if (TEST_TO_DO == 1)
#for i (1,5000)
integer j##i = 1
x = j##i
x = j##i
#endfor
#elseif (TEST_TO_DO == 2)
#for i (1,5000)
J##i = 1
x = J##i
x = J##i
#endfor
#else
PauseTimer(GetExpiredTimer()) ; DisplayTextToPlayer(GetLocalPlayer(),0,0,"invalid TEST_TO_DO")
#endif
// DisplayTextToPlayer(GetLocalPlayer(),0,0,"limit op not reached")
}
private nothing init() {
TimerStart(CreateTimer(),PERIOD,true,function Test)
}
}
Result : 30 fps for locals and 58 fps for globals (just starting to lost fps, my max is 60 fps)
Conclusion : Since it's only a theoretical use i can't conclude yet
PS : I'm open to all critics, comments and suggestions as long they are constructive.
Last edited: