Which is faster?
#1

I got:

pawn Код:
#define JOHN    0
#define DOG     1
#define DRAKE   2
#define MILEY   3
then i make a stock like this one (uhh its just an example)

pawn Код:
stock MakePlayerDance(playerid)
{
    //
}
now under OnPlayerSpawn , I want to make all of them dance, so i got 2 solutions, either i make a loop or i just use switch statements

1-
pawn Код:
for(new i = 0; i < 4; ++i)  MakePlayerDance(i);
or 2-

pawn Код:
switch(playerid)
{
      case JOHN:
}
which is faster / less memory using ( btw in my real script i got over 36 case)
(+ please don't tell me you could use foreach, in my real script its not about players, i jus didnt find a good example)
Reply
#2

wow! this reached the 3rd page in almost 2 hours! bump
Reply
#3

Why don't you check for yourself? You can check the time your code takes to execute with GetTickCount. I don't think the difference is noticeable at all though, but i bet the switch is the fastest
Reply
#4

okey, one more question, is this the same thing (in speed/performance)?
pawn Код:
for(new i = 0; i < 4; ++i)  MakePlayerDance(i);
as
pawn Код:
MakePlayerDance(0);
MakePlayerDance(1);
MakePlayerDance(2);
MakePlayerDance(3);
Reply
#5

Great, thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)