BlueX

Benchmark

Jun 28th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.40 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #pragma tabsize 0
  4.  
  5. // =================================================================================
  6.  
  7. #define msgbox DIALOG_STYLE_MSGBOX
  8. #define input DIALOG_STYLE_INPUT
  9. #define list DIALOG_STYLE_LIST
  10. #define pass DIALOG_STYLE_PASSWORD
  11.  
  12. #if !defined isnull
  13.     #define isnull(%1) \
  14.                 ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
  15. #endif
  16.  
  17. #define addDialogHandler(%0) \
  18.     forward callDialog_%0(playerid, response, listitem, inputtext[]); \
  19.     public callDialog_%0(playerid, response, listitem, inputtext[])
  20.  
  21. #define Dialog:%0(%1,%2,%3,%4) \
  22.     forward callDialog_%0(%1,%2,%3,%4); \
  23.     public callDialog_%0(%1,%2,%3,%4)
  24.  
  25.  
  26. static CALL_DIALOG [ 24 ] ;
  27.  
  28. OnDialogResponseProcessor ( playerid , dialogid , response , listitem , inputtext [] );
  29.  
  30. public OnDialogResponseProcessor ( playerid , dialogid , response , listitem , inputtext [] )
  31. {
  32.     if ( dialogid ) format ( CALL_DIALOG , 24 , "callDialog_%d" , dialogid ) ;
  33.     return ( ( funcidx ( CALL_DIALOG ) != -1 ) ? ( CallLocalFunction ( CALL_DIALOG , "ddds" , playerid , response , listitem , isnull( inputtext ) ? ( "\1" ) : ( inputtext ) ) ) : ( 0 ) ) ;
  34. }
  35.  
  36. // =================================================================================
  37.  
  38. #define START_BENCH(%0); {new __a=%0,__b=0,__c,__d=GetTickCount(),__e=1;do{}\
  39.     while(__d==GetTickCount());__c=GetTickCount();__d=__c;while(__c-__d<__a||\
  40.     __e){if(__e){if(__c-__d>=__a){__e=0;__c=GetTickCount();do{}while(__c==\
  41.     GetTickCount());__c=GetTickCount();__d=__c;__b=0;}}{
  42.    
  43. #define FINISH_BENCH(%0); }__b++;__c=GetTickCount();}printf(" Bench for "\
  44.     %0": executes, by average, %.2f times/ms.",floatdiv(__b,__a));}
  45.    
  46.  
  47. enum
  48. {
  49.     DIALOG_NULL,
  50.     DIALOG_NORMAL = 12,
  51.     DIALOG_PROCESSOR = 22,
  52.     DIALOG_SWITCH = 32,
  53.     DIALOG_PROCESSOR1 = 20,
  54.     DIALOG_PROCESSOR2 = 21
  55. };
  56.  
  57. main()
  58. {
  59.     print("\n----------------------------------");
  60.     print(" Blank Gamemode by your name here");
  61.     print("----------------------------------\n");
  62. }
  63.  
  64.  
  65. public OnGameModeInit()
  66. {
  67.     SetGameModeText("Blank Script");
  68.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  69.     START_BENCH( 1000 );
  70.     {
  71.         CallLocalFunction("OnDialogResponseProcessor","dddds",0,DIALOG_PROCESSOR,1,0,"\1");
  72.     }
  73.     FINISH_BENCH("Dialog Processor");
  74.    
  75.     START_BENCH( 1000 );
  76.     {
  77.         CallLocalFunction("OnDialogResponse","dddds",0,DIALOG_NORMAL,1,0,"\1");
  78.     }
  79.     FINISH_BENCH("Dialog Normal");
  80.    
  81.     START_BENCH( 1000 );
  82.     {
  83.         CallLocalFunction("OnDialogResponseSwitch","dddds",0,DIALOG_SWITCH,1,0,"\1");
  84.     }
  85.     FINISH_BENCH("Dialog Switch");
  86.     return 1;
  87. }
  88.  
  89. public OnGameModeExit()
  90. {
  91.     return 1;
  92. }
  93.  
  94. public OnDialogResponse ( playerid , dialogid , response , listitem , inputtext [] )
  95. {
  96.     if(dialogid == 10)
  97.         return 1;
  98.     else if(dialogid == 11)
  99.         return 1;
  100.     else if(dialogid == DIALOG_NORMAL)
  101.         return 1;
  102.     return 1;
  103. }
  104.  
  105. OnDialogResponseSwitch ( playerid , dialogid , response , listitem , inputtext [] );
  106. public OnDialogResponseSwitch ( playerid , dialogid , response , listitem , inputtext [] )
  107. {
  108.  
  109.     switch(dialogid)
  110.     {
  111.         case 30:
  112.             return 1;
  113.         case 31:
  114.             return 1;
  115.         case DIALOG_SWITCH:
  116.             return 1;
  117.     }
  118.     return 1;
  119. }
  120.  
  121. Dialog:DIALOG_PROCESSOR( playerid, response, listitem, inputtext[])
  122. {
  123.     return 1;
  124. }
  125. Dialog:DIALOG_PROCESSOR1(playerid, response, listitem, inputtext[])
  126. {
  127.     return 1;
  128. }
  129. Dialog:DIALOG_PROCESSOR2( playerid, response, listitem, inputtext[])
  130. {
  131.     return 1;
  132. }
Advertisement
Add Comment
Please, Sign In to add comment