Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #pragma tabsize 0
- #define START_BENCH(%0); \
- { \
- new iMilliSeconds = %0, iCount = 0, iStartTick, iTick; \
- do { } while ( iStartTick == GetTickCount( ) ); \
- iTick = GetTickCount( ); \
- iStartTick = iTick; \
- while ( iTick - iStartTick < iMilliSeconds ) \
- { \
- ++iCount;
- #define FINISH_BENCH(%0); \
- iTick = GetTickCount( ); \
- } \
- printf( " Bench for " %0 ": executes, by average, %d times/ms.", iCount / iMilliSeconds ); \
- }
- stock strcpy_1(dest[], source[], len = -1)
- {
- new
- i;
- if (len == -1) len = strlen(source);
- while (i < len) dest[i] = source[i++];
- dest[i] = 0;
- }
- stock strcpy_2(dest[], source[])
- {
- new i = -1;
- do
- dest[++i] = source[i];
- while ( dest[ i ] );
- }
- public OnFilterScriptInit( )
- {
- new szSource[ ] = \"cadnifgjghaj6he890fJT#)=ASJ\\sdfaf£\sf\v\\asfai2r2j90J)=J#)=Jf09ASFASPfasiof(ShcvnoAfsaj2389ajfa";
- new szDest[ 1234 ];
- printf( "String copying benchmark" );
- START_BENCH( 1000 );
- memcpy( szDest, szSource, _, ( strlen( szSource ) + 1 ) * 4 );
- FINISH_BENCH( "memcpy" );
- START_BENCH( 1000 );
- format( szDest, sizeof( szDest ), "%s", szSource );
- FINISH_BENCH( "format" );
- START_BENCH( 1000 );
- strcpy_1( szDest, szSource );
- FINISH_BENCH( "strcpy 1" );
- START_BENCH( 1000 );
- strcpy_2( szDest, szSource );
- FINISH_BENCH( "strcpy 2" );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement