Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.33 KB | None | 0 0
  1. #include                    a_samp
  2.  
  3. #define system::                        system_
  4.  
  5. // Slice's benchmarking macros.
  6. #define START_BENCH(%0); {new __a=%0,__b=0,__c,__d=GetTickCount(),__e=1;do{}\
  7.     while(__d==GetTickCount());__c=GetTickCount();__d=__c;while(__c-__d<__a||\
  8.     __e){if(__e){if(__c-__d>=__a){__e=0;__c=GetTickCount();do{}while(__c==\
  9.     GetTickCount());__c=GetTickCount();__d=__c;__b=0;}}{
  10.    
  11. #define FINISH_BENCH(%0); }__b++;__c=GetTickCount();}printf(" Bench for "\
  12.     %0": executes, by average, %.2f times/ms.",floatdiv(__b,__a));}
  13.  
  14. public
  15.     OnFilterScriptInit()
  16. {
  17.     START_BENCH( 10000 );
  18.     {
  19.         system::strCheck("PLAYMAKER", "PLAYMAKER");
  20.     }
  21.     FINISH_BENCH( "system::strCheck" );
  22.     START_BENCH( 10000 );
  23.     {
  24.         strcmp("PLAYMAKER", "PLAYMAKER");
  25.     }
  26.     FINISH_BENCH( "strcmp" );
  27.     return true;
  28. }
  29.  
  30. /*
  31.     system::strCheck:
  32.         Check if the strings ('s_' and '_s') match each other.
  33.  
  34.     Arguments:
  35.         s_[]    First string.
  36.         _s[]    Second string.
  37.  
  38.     Returns:
  39.         ? False, True.
  40.  
  41.     Notes:
  42.         Similar to strcmp, but faster.
  43. */
  44. stock
  45.     system::strCheck(s_[], _s[])
  46. {
  47.     new
  48.             c = 0
  49.           , bool:b = true
  50.     ;
  51.     while (max(strlen(s_), strlen(_s)) != c)
  52.     {
  53.         if (s_[c] != _s[c])
  54.         {
  55.             b
  56.                 = false
  57.             ;
  58.         }
  59.         ++
  60.             c
  61.         ;
  62.     }
  63.     if (b)
  64.     {
  65.         return true;
  66.     }
  67.     else
  68.     {
  69.         return false;
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement