18.11.2012, 10:13
(
Последний раз редактировалось Yousha_Aleayoub; 18.11.2012 в 10:50.
)
lol. do you know about benchmarking? so do its yourself.
I never says anything without a reason/proof.
Normal condition: 10760068 MS
Ternary condition: 10955372 MS
EACH BENCHMARK SHOULD BE DONE SEPARATELY.
Ternary conditions are little slower than normal conditions(if/else...).
I never says anything without a reason/proof.
Normal condition: 10760068 MS
Ternary condition: 10955372 MS
Код:
#include <a_samp> main() { new StartTick, StopTick; StartTick = GetTickCount(); for(new i; i < 1000000; i ++) { StartTick = (StartTick == 1) ? 0 : 1; StartTick = (StartTick == 1) ? 0 : 1; StartTick = (StartTick == 1) ? 0 : 1; StartTick = (StartTick == 1) ? 0 : 1; StartTick = (StartTick == 1) ? 0 : 1; } StopTick = GetTickCount(); printf("Ternary condition: %d MS", StopTick - StartTick); return; }
Код:
#include <a_samp> main() { new StartTick, StopTick; StartTick = GetTickCount(); for(new i; i < 1000000; i ++) { if(StartTick == 1) { StartTick = 0; } else { StartTick = 1; } if(StartTick == 1) { StartTick = 0; } else { StartTick = 1; } if(StartTick == 1) { StartTick = 0; } else { StartTick = 1; } if(StartTick == 1) { StartTick = 0; } else { StartTick = 1; } if(StartTick == 1) { StartTick = 0; } else { StartTick = 1; } } StopTick = GetTickCount(); printf("Normal condition: %d MS", StopTick - StartTick); return; }
Ternary conditions are little slower than normal conditions(if/else...).