Advertisement
ZiGGi

Untitled

Feb 16th, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.93 KB | None | 0 0
  1. // Profiler v1.3 (copyright (c) 2014-2017 Daniel_Cortez)  \\ Pro-Pawn.ru
  2. // Условия использования данного кода: http://pro-pawn.ru/showthread.php?12585
  3.  
  4. #tryinclude <a_samp>
  5. /*======== Настройки =========================================================*/
  6. // Кол-во итераций в циклах.
  7. const PROFILER_ITERATIONS_MAJOR = 10_000;
  8. const PROFILER_ITERATIONS_MINOR = 1_000;
  9.  
  10. new const code_snippets_names[4][] =
  11. {
  12.     {"Snegovik1337"},
  13.     {"DeimoS"},
  14.     {"Long-"},
  15.     {"ziggi"}
  16. };
  17.  
  18. enum e_pInfo
  19. {
  20.     pSex,
  21.     pSkin
  22. };
  23. new pInfo[MAX_PLAYERS][e_pInfo];
  24. new Random_Skin_Male[] =
  25. {
  26.     292, 293
  27. };
  28. new Random_Skin_Female[] =
  29. {
  30.     12, 138
  31. };
  32. new Random_Skin[2][] =
  33. {
  34.     {292, 293},
  35.     {12, 138}
  36. };
  37.  
  38. #define Prerequisites();\
  39.     new listitem = 1;
  40.  
  41.  
  42. #define CodeSnippet0();\
  43.     pInfo[999][pSex] = listitem+1;\
  44.     pInfo[999][pSkin] = (listitem == 0)?\
  45.     (Random_Skin_Male[random(sizeof(Random_Skin_Male))]):(Random_Skin_Female[random(sizeof(Random_Skin_Female))]);
  46.  
  47. #define CodeSnippet1(); \
  48.     switch(listitem) {\
  49.         case 0: {\
  50.             pInfo[999][pSex] = 1;\
  51.             pInfo[999][pSkin] = Random_Skin_Male[random(sizeof(Random_Skin_Male))];\
  52.         }\
  53.         case 1: {\
  54.             pInfo[999][pSex] = 2;\
  55.             pInfo[999][pSkin] = Random_Skin_Female[random(sizeof(Random_Skin_Female))];\
  56.         }\
  57.     }
  58.  
  59. #define CodeSnippet2();\
  60.     pInfo[999][pSex] = listitem + 1;\
  61.     if(pInfo[999][pSex] == 1)\
  62.         pInfo[999][pSkin] = Random_Skin_Male[random(sizeof(Random_Skin_Male))];\
  63.     else\
  64.         pInfo[999][pSkin] = Random_Skin_Female[random(sizeof(Random_Skin_Female))];
  65.  
  66. #define CodeSnippet3();\
  67.     pInfo[999][pSex] = listitem + 1;\
  68.     pInfo[999][pSkin] = Random_Skin[listitem][random(sizeof(Random_Skin[]))];
  69. /*======== Конец настроек ===================================================*/
  70.  
  71.  
  72.  
  73. // Не рекомендую изменять следующий код, если вы в нём не разбираетесь.
  74. #if defined _samp_included
  75.     #define LINE_BREAK ""
  76. #else
  77.     #define LINE_BREAK "\n"
  78.     #include <core>
  79.     #include <time>
  80.     #define GetTickCount() tickcount()
  81. #endif
  82.  
  83. #define _PROFILE_START(%0)\
  84.     __t[%0] = GetTickCount();\
  85.     for (__j = 0; __j < PROFILER_ITERATIONS_MINOR; ++__j)\
  86.     {
  87. #define _PROFILE_END(%0)        __t[%0] = GetTickCount()-__t[%0]
  88.  
  89. #if defined _samp_included
  90.     #define PROFILE_START(%0);    _PROFILE_START(%0)
  91.     #define PROFILE_END(%0);\
  92.         }\
  93.         _PROFILE_END(%0);
  94. #else
  95.     #define PROFILE_START(%0);    _PROFILE_START(%0)
  96.     #define PROFILE_END(%0);\
  97.         }\
  98.         if ((_PROFILE_END(%0)) < 0) {--__i; continue;}
  99. #endif
  100.  
  101. #define CODE_SNIPPET_EXISTS(%0)\
  102.     (sizeof(code_snippets_names) >= ((%0) + 1)) && (defined CodeSnippet%0)
  103.  
  104.  
  105. new code_snippets_time[sizeof(code_snippets_names)] = {0, ...};
  106.  
  107. main()
  108. {
  109.     new __i, __j, __t[sizeof(code_snippets_names)];
  110.     #emit    zero.pri
  111.     #emit    lctrl        7
  112.     #emit    stor.s.pri    __i
  113. #if CODE_SNIPPET_EXISTS(2)
  114.     static const ending[] =
  115.     #if (sizeof(code_snippets_names) <= 4)
  116.         "ка";
  117.     #else
  118.         "ков";
  119.     #endif
  120.     printf(
  121.         "Тестирование: %d отрыв%s кода." LINE_BREAK,
  122.         sizeof(code_snippets_names), ending
  123.     );
  124. #else
  125.     printf(
  126.         "Тестирование: <%s> vs <%s>" LINE_BREAK,
  127.         code_snippets_names[0], code_snippets_names[1]
  128.     );
  129. #endif
  130.     static const JIT_status_strings[2][] =
  131.         {"интерпретируемый", "с JIT-компиляцией"};
  132.     printf(
  133.         "Режим: %s, %dx%d итераций.\a" LINE_BREAK,
  134.         JIT_status_strings[__i],
  135.         PROFILER_ITERATIONS_MAJOR, PROFILER_ITERATIONS_MINOR
  136.     );
  137.     Prerequisites();
  138.     for (__i = 0; __i < PROFILER_ITERATIONS_MAJOR; ++__i)
  139.     {
  140.         PROFILE_START(0);
  141.         CodeSnippet0();
  142.         PROFILE_END(0);
  143.         PROFILE_START(1);
  144.         CodeSnippet1();
  145.         PROFILE_END(1);
  146. #if CODE_SNIPPET_EXISTS(2)
  147.         PROFILE_START(2);
  148.         CodeSnippet2();
  149.         PROFILE_END(2);
  150. #endif
  151. #if CODE_SNIPPET_EXISTS(3)
  152.         PROFILE_START(3);
  153.         CodeSnippet3();
  154.         PROFILE_END(3);
  155. #endif
  156. #if CODE_SNIPPET_EXISTS(4)
  157.         PROFILE_START(4);
  158.         CodeSnippet4();
  159.         PROFILE_END(4);
  160. #endif
  161. #if CODE_SNIPPET_EXISTS(5)
  162.         PROFILE_START(5);
  163.         CodeSnippet5();
  164.         PROFILE_END(5);
  165. #endif
  166. #if CODE_SNIPPET_EXISTS(6)
  167.         PROFILE_START(6);
  168.         CodeSnippet6();
  169.         PROFILE_END(6);
  170. #endif
  171. #if CODE_SNIPPET_EXISTS(7)
  172.         PROFILE_START(7);
  173.         CodeSnippet7();
  174.         PROFILE_END(7);
  175. #endif
  176. #if CODE_SNIPPET_EXISTS(8)
  177.         PROFILE_START(8);
  178.         CodeSnippet8();
  179.         PROFILE_END(8);
  180. #endif
  181. #if CODE_SNIPPET_EXISTS(9)
  182.         PROFILE_START(9);
  183.         CodeSnippet9();
  184.         PROFILE_END(9);
  185. #endif
  186. #if CODE_SNIPPET_EXISTS(10)
  187.         PROFILE_START(10);
  188.         CodeSnippet10();
  189.         PROFILE_END(10);
  190. #endif
  191. #if CODE_SNIPPET_EXISTS(11)
  192.         PROFILE_START(11);
  193.         CodeSnippet11();
  194.         PROFILE_END(11);
  195. #endif
  196. #if CODE_SNIPPET_EXISTS(12)
  197.         PROFILE_START(12);
  198.         CodeSnippet12();
  199.         PROFILE_END(12);
  200. #endif
  201. #if CODE_SNIPPET_EXISTS(13)
  202.         PROFILE_START(13);
  203.         CodeSnippet13();
  204.         PROFILE_END(13);
  205. #endif
  206. #if CODE_SNIPPET_EXISTS(14)
  207.         PROFILE_START(14);
  208.         CodeSnippet14();
  209.         PROFILE_END(14);
  210. #endif
  211. #if CODE_SNIPPET_EXISTS(15)
  212.         PROFILE_START(15);
  213.         CodeSnippet15();
  214.         PROFILE_END(15);
  215. #endif
  216.         for (__j = 0; __j < sizeof(code_snippets_names); ++__j)
  217.             code_snippets_time[__j] += __t[__j];
  218.     }
  219.     for (__i = 0; __i < sizeof(code_snippets_names); ++__i)
  220.         printf(
  221.             "%s: %d" LINE_BREAK,
  222.             code_snippets_names[__i], code_snippets_time[__i]
  223.         );
  224.     printf("\a\a" LINE_BREAK);
  225. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement