03.07.2012, 10:35
Hi guys,
I created a little test, to check which loop(I mean for( ) and while( )) is faster. The results are very strange! I want to know, why there is a very big difference.
Here is the results:
Thanks.
I created a little test, to check which loop(I mean for( ) and while( )) is faster. The results are very strange! I want to know, why there is a very big difference.
pawn Код:
new
var,
time
;
time = GetTickCount( );
for( new i; i < 10000000; i++ )
{
for( var = 0; var < 100; var++ ) // using for( ) loop
{
SendClientMessage( 0, -1, "" );
}
}
printf( "result1: %d ms", GetTickCount( ) - time );
time = GetTickCount( );
for( new i; i < 10000000; i++ )
{
while( var < 100 ) // using while( ) loop
{
SendClientMessage( 0, -1, "" );
var++;
}
}
printf( "result2: %d ms", GetTickCount( ) - time );
Код:
[13:40:26] result1: 39798 ms [13:40:26] result2: 277 ms