Advertisement
Guest User

Untitled

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