03.09.2014, 12:44
(
Последний раз редактировалось JM_Millers; 05.09.2014 в 07:54.
)
Hello there.
I've noticed that in this theard Slice said, that this is the fastest players loop:
But actually it isn't, because the decrement in PAWN is more faster that increment and the fastest players loop is:
Proofs:
I know that with a small number of iterations it doesn't matter, but in the cases, when you're making loop with the vehicles (which limit is 2000) or the large strings it's really works faster.
Thank you for reading it and sorry for the mistakes.
I've noticed that in this theard Slice said, that this is the fastest players loop:
pawn Код:
for ( new slots = GetMaxPlayers( ), i; i < slots; i++ )
{
if ( !IsPlayerConnected( i ) )
continue;
// code for connected players
}
pawn Код:
for(new i=GetMaxPlayers()-1; i != -1; i--)
{
if !IsPlayerConnected(i) *then continue;
}
pawn Код:
main()
{
new tick = GetTickCount();
for ( new slots = getMaxPlayers( ), i; i < slots; i++ )
{}
printf("- %d", GetTickCount()-tick);
tick = GetTickCount();
for(new i=getMaxPlayers(); i != -1; i-- )
{}
printf("- %d", GetTickCount()-tick);
return 0;
}
getMaxPlayers() return 10000000;
Quote:
- 378 - 397 |
Thank you for reading it and sorry for the mistakes.