24.07.2018, 10:16
Quote:
Using some thing like "case 0..44" is in-efficient because it is like creating 44 if statements.
source: http://forum.sa-mp.com/showpost.php?...0&postcount=15 |
Код:
#include <a_samp> public OnFilterScriptInit() { new tick = GetTickCount(); for(new i = 0; i < 1000000; i++) { switch(random(100)) { case 0..44: { } case 45..89: { } case 90..99: { } } } printf("Took: %d", GetTickCount() - tick); tick = GetTickCount(); for(new i = 0; i < 1000000; i++) { new val = random(100); if(val >= 0 && val <= 44) { } else if(val >= 45 && val <= 89) { } else if(val >= 90 && val <= 99) { } } printf("Took: %d", GetTickCount() - tick); }
PHP код:
Filterscript 'w.amx' unloaded.
Took: 92
Took: 232
Filterscript 'w.amx' loaded.