05.05.2015, 21:45
2,000 iterations isn't that much. Just saying.
This code runs a loop with 2,000 iterations 50 times, which comes out to 100,000 iterations in total. This only takes 1-2 ms.
Now depending on the code you'll have in there, you'll probably dealing with less than 50 milliseconds of code execution time.
In my experience, this is the best way:
pawn Код:
new
tick = GetTickCount();
for (new i = 0; i < 50; i ++)
{
for (new j = 0; j < 2000; j ++) { }
}
printf("%d ms", GetTickCount() - tick);
Now depending on the code you'll have in there, you'll probably dealing with less than 50 milliseconds of code execution time.
In my experience, this is the best way:
pawn Код:
for (new i = 0, j = GetVehiclePoolSize(); i <= j; i ++)
{
if (!IsValidVehicle(i) || !IsVehicleStreamedIn(i, playerid))
continue;
// Check if a player is near a trunk, show a dialog, etc.
}