11.07.2015, 23:46
Code used:
Results:
So SVars are slower only at setting strings.
pawn Код:
public OnFilterScriptInit( )
{
new liTick;
#define ITERS 1000000
//============================[ Set Int ]===================================
// GVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
SetGVarInt( "TestSI", 69 );
printf( "INT: Set: GVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
// SVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
SetSVarInt( "TestSI", 69 );
printf( "INT: Set: SVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
//============================[ Get Int ]===================================
// GVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
GetGVarInt( "TestGI" );
printf( "INT: Get: GVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
// SVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
GetSVarInt( "TestGI" );
printf( "INT: Get: SVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
//===========================[ Set Float ]==================================
// GVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
SetGVarFloat( "TestSF", 69.00 );
printf( "FLOAT: Set: GVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
// SVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
SetSVarFloat( "TestSF", 69.00 );
printf( "FLOAT: Set: SVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
//===========================[ Get Float ]==================================
// GVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
GetGVarFloat( "TestGF" );
printf( "FLOAT: Get: GVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
// SVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
GetSVarFloat( "TestGF" );
printf( "FLOAT: Get: SVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
//===========================[ Set String ]=================================
// GVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
SetGVarString( "TestSS", "Sixty Nine" );
printf( "STRING: Set: GVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
// SVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
SetSVarString( "TestSS", "Sixty Nine" );
printf( "STRING: Set: SVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
//===========================[ Get String ]=================================
new lsString[ 16 ];
// GVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
GetGVarString( "TestGS", lsString, 16 );
printf( "STRING: Get: GVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
// SVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
GetSVarString( "TestGS", lsString, 16 );
printf( "STRING: Get: SVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
return 1;
}
Quote:
INT: Set: GVar speed for 1000000 iterations: 237ms INT: Set: SVar speed for 1000000 iterations: 170ms INT: Get: GVar speed for 1000000 iterations: 234ms INT: Get: SVar speed for 1000000 iterations: 162ms FLOAT: Set: GVar speed for 1000000 iterations: 229ms FLOAT: Set: SVar speed for 1000000 iterations: 179ms FLOAT: Get: GVar speed for 1000000 iterations: 218ms FLOAT: Get: SVar speed for 1000000 iterations: 167ms STRING: Set: GVar speed for 1000000 iterations: 309ms STRING: Set: SVar speed for 1000000 iterations: 344ms STRING: Get: GVar speed for 1000000 iterations: 223ms STRING: Get: SVar speed for 1000000 iterations: 175ms |