Is while or for faster? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Is while or for faster? (
/showthread.php?tid=181699)
Is while or for faster? -
Memoryz - 06.10.2010
Which one is faster or is better to use?
While
pawn Код:
new idx;
while (idx < 500)
{
DoSomething();
idx++;
}
For:
pawn Код:
for(new c=0;c<500;c++)
{
DoSomething();
}
Re: Is while or for faster? -
bigcomfycouch - 06.10.2010
In my tests (
http://pastebin.com/Hj0tJjCx ), while was slightly faster. However, the difference was 7800 ms for 'for' and 7300 ms for 'while' at 100,000,000 loops, which is but an infinitesimal difference.