ZiGGi

Speed Test(dcmd vs zcmd vs if)

Nov 28th, 2011
769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.28 KB | None | 0 0
  1. #include <..\compiler\includes\a_samp>
  2. #include "zcmd"
  3.  
  4. #define C_TICK      50000
  5.  
  6. #define ncmd(%0,%1,%2) \
  7.     if(!strcmp(%0,#/%1,true,%2) && ((%0[%2+1] == ' ') || (%0[%2+1] == 0))) \
  8.         return ncmd_%1(playerid,%0[%2+1+1])
  9.  
  10. #define dcmd(%1,%2,%3) \
  11.     if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) \
  12.         return 1
  13.  
  14. main()
  15. {
  16.     new tick;
  17.  
  18.  
  19.    
  20.     // ----------
  21.     tick = GetTickCount();
  22.     for (new i=0;i<C_TICK;i++)
  23.     {
  24.         CallRemoteFunction("OnPlayerCommandText","is",0,"/test_zcmd 0 param1");
  25.     }
  26.     printf("zcmd: %d",GetTickCount() - tick);
  27.  
  28.  
  29.    
  30.     // ----------
  31.     tick = GetTickCount();
  32.     for (new i=0;i<C_TICK;i++)
  33.     {
  34.         CallRemoteFunction("old_OnPlayerCommandText","is",0,"/test_old 0 param1");
  35.     }
  36.     printf("old: %d",GetTickCount() - tick);
  37.  
  38.  
  39.    
  40.     // ----------
  41.     tick = GetTickCount();
  42.     for (new i=0;i<C_TICK;i++)
  43.     {
  44.         CallRemoteFunction("new_OnPlayerCommandText","is",0,"/test_new 0 param1");
  45.     }
  46.     printf("new: %d",GetTickCount() - tick);
  47.  
  48.  
  49.    
  50.     // ----------
  51.     tick = GetTickCount();
  52.     for (new i=0;i<C_TICK;i++)
  53.     {
  54.         CallRemoteFunction("dcmd_OnPlayerCommandText","is",0,"/test_dcmd 0 param1");
  55.     }
  56.     printf("dcmd: %d",GetTickCount() - tick);
  57.  
  58.    
  59.    
  60. }
  61. // ----------
  62. forward OnPlayerCommandText(playerid,cmdtext[]);
  63. public OnPlayerCommandText(playerid,cmdtext[])
  64. {
  65.     zcmd_OnPlayerCommandText(playerid,cmdtext);
  66.     return 0;
  67. }
  68. COMMAND:test_zcmd(playerid, params[])
  69. {
  70.     return 1;
  71. }
  72.  
  73.  
  74.  
  75. // ----------
  76. forward old_OnPlayerCommandText(playerid,cmdtext[]);
  77. public old_OnPlayerCommandText(playerid,cmdtext[])
  78. {
  79.     if(!strcmp(cmdtext,"/test_old",true,9))
  80.     {
  81.         return 1;
  82.     }
  83.     return 0;
  84. }
  85.  
  86.  
  87.  
  88.  
  89.  
  90. // ----------
  91. forward new_OnPlayerCommandText(playerid,cmdtext[]);
  92. public new_OnPlayerCommandText(playerid,cmdtext[])
  93. {
  94.     ncmd(cmdtext,test_new,8);
  95.     return 0;
  96. }
  97.  
  98. #define NCMD:%1(%2) \
  99.     forward ncmd_%1(%2); \
  100.     public ncmd_%1(%2)
  101.  
  102. NCMD:test_new(playerid,params[])
  103. {
  104.     return 1;
  105. }
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115. // ----------
  116.  
  117. forward dcmd_OnPlayerCommandText(playerid,cmdtext[]);
  118. public dcmd_OnPlayerCommandText(playerid,cmdtext[])
  119. {
  120.     dcmd(test_dcmd,9,cmdtext);
  121.     return 1;
  122. }
  123.  
  124. forward dcmd_test_dcmd(playerid,params[]);
  125. public dcmd_test_dcmd(playerid,params[])
  126. {
  127.     return 1;
  128. }
  129.  
  130.  
Advertisement
Add Comment
Please, Sign In to add comment