Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #include <a_samp>
- #define START_BENCH(%0); {new __a=%0,__b=0,__c,__d=GetTickCount(),__e=1;do{}\
- while(__d==GetTickCount());__c=GetTickCount();__d=__c;while(__c-__d<__a||\
- __e){if(__e){if(__c-__d>=__a){__e=0;__c=GetTickCount();do{}while(__c==\
- GetTickCount());__c=GetTickCount();__d=__c;__b=0;}}{
- #define FINISH_BENCH(%0); }__b++;__c=GetTickCount();}printf(" Bench for "\
- %0": executes, by average, %.2f times/ms.",floatdiv(__b,__a));}
- static stringformat[64],stringstrcat[64];
- public OnFilterScriptInit()
- {
- START_BENCH(10000);
- {
- format(stringformat,sizeof(stringformat),"Hello");
- format(stringformat,sizeof(stringformat),"%s World",stringformat);
- }
- FINISH_BENCH("stringformat");
- START_BENCH(10000);
- {
- strcat(stringstrcat,"Hello ",sizeof(stringstrcat));
- strcat(stringstrcat,"World",sizeof(stringstrcat));
- }
- FINISH_BENCH("stringstrcat");
- printf("bench 1: %s,bench 2: %s",stringformat,stringstrcat);
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement