Advertisement
OKStyle

Trim LCC 2015

Nov 22nd, 2015
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.10 KB | None | 0 0
  1. #include <a_samp>
  2. public OnFilterScriptInit()
  3. {
  4.     print(" ");
  5.     new time = GetTickCount();
  6.     for(new i = 0; i < 100000; i++)
  7.     {
  8.         new str[] = "              любая        строка           для             теста              ";
  9.         RemoveSpaces_OK(str);
  10.     }
  11.     printf("OKStyle - %d мс", GetTickCount() - time);
  12.     time = GetTickCount();
  13.     for(new i = 0; i < 100000; i++)
  14.     {
  15.         new str[] = "              любая        строка           для             теста              ";
  16.         RemoveSpaces_MellikJKE(str);
  17.     }
  18.     printf("MellikJKE - %d мс", GetTickCount() - time);
  19.     time = GetTickCount();
  20.     for(new i = 0; i < 100000; i++)
  21.     {
  22.         new str[] = "              любая        строка           для             теста              ";
  23.         RemoveSpaces_regnaR(str);
  24.     }
  25.     printf("regnaR - %d мс", GetTickCount() - time);
  26.     time = GetTickCount();
  27.     for(new i = 0; i < 100000; i++)
  28.     {
  29.         new str[] = "              любая        строка           для             теста              ";
  30.         RemoveSpaces_DC(str);
  31.     }
  32.     printf("Daniel_Cortez - %d мс", GetTickCount() - time);
  33.     time = GetTickCount();
  34.     for(new i = 0; i < 100000; i++)
  35.     {
  36.         new str[] = "              любая        строка           для             теста              ";
  37.         RemoveSpaces_Denwer(str);
  38.     }
  39.     printf("Denwer - %d мс", GetTickCount() - time);
  40.     time = GetTickCount();
  41.     for(new i = 0; i < 100000; i++)
  42.     {
  43.         new str[] = "              любая        строка           для             теста              ";
  44.         RemoveSpaces_VT(str);
  45.     }
  46.     printf("Valera_Trefilov - %d мс", GetTickCount() - time);
  47.     time = GetTickCount();
  48.     for(new i = 0; i < 100000; i++)
  49.     {
  50.         new str[] = "              любая        строка           для             теста              ";
  51.         RemoveSpaces_ziggi(str);
  52.     }
  53.     printf("ziggi - %d мс", GetTickCount() - time);
  54.     time = GetTickCount();
  55.     for(new i = 0; i < 100000; i++)
  56.     {
  57.         new str[] = "              любая        строка           для             теста              ";
  58.         RemoveSpaces_g3o0or(str);
  59.     }
  60.     printf("g3o0or - %d мс", GetTickCount() - time);
  61.     time = GetTickCount();
  62.     for(new i = 0; i < 100000; i++)
  63.     {
  64.         new str[] = "              любая        строка           для             теста              ";
  65.         RemoveSpaces_polander(str);
  66.     }
  67.     printf("polander - %d мс", GetTickCount() - time);
  68.     time = GetTickCount();
  69.     for(new i = 0; i < 100000; i++)
  70.     {
  71.         new str[] = "              любая        строка           для             теста              ";
  72.         RemoveSpaces_Untonyst(str);
  73.     }
  74.     printf("Untonyst - %d мс", GetTickCount() - time);
  75.     time = GetTickCount();
  76.     for(new i = 0; i < 100000; i++)
  77.     {
  78.         new str[] = "              любая        строка           для             теста              ";
  79.         RemoveSpaces_polander(str);
  80.     }
  81.     printf("polander - %d мс", GetTickCount() - time);
  82.     time = GetTickCount();
  83.     for(new i = 0; i < 100000; i++)
  84.     {
  85.         new str[] = "              любая        строка           для             теста              ";
  86.         RemoveSpaces_iBorland(str);
  87.     }
  88.     printf("iBorland - %d мс", GetTickCount() - time);
  89.     time = GetTickCount();
  90.     for(new i = 0; i < 100000; i++)
  91.     {
  92.         new str[] = "              любая        строка           для             теста              ";
  93.         RemoveSpaces_Tracer(str);
  94.     }
  95.     printf("Tracer - %d мс", GetTickCount() - time);
  96.     time = GetTickCount();
  97.     for(new i = 0; i < 100000; i++)
  98.     {
  99.         new str[] = "              любая        строка           для             теста              ";
  100.         RemoveSpaces_ProG(str);
  101.     }
  102.     printf("ProG - %d мс", GetTickCount() - time);
  103.     time = GetTickCount();
  104.     for(new i = 0; i < 100000; i++)
  105.     {
  106.         new str[] = "              любая        строка           для             теста              ";
  107.         RemoveSpaces_KD(str);
  108.     }
  109.     printf("Kenny_Dalglish - %d мс", GetTickCount() - time);
  110.     time = GetTickCount();
  111.     for(new i = 0; i < 100000; i++)
  112.     {
  113.         new str[] = "              любая        строка           для             теста              ";
  114.         RemoveSpaces_ZL(str);
  115.     }
  116.     printf("Zaur_Lumanov - %d мс", GetTickCount() - time);
  117.     print(" ");
  118. // Old Test
  119. /*
  120.     new str[] = "              любая        строка           для             теста              ";
  121.     time = GetTickCount();
  122.     for(new i = 0; i < 100000; i++) RemoveSpaces_OK(str);
  123.     printf("OKStyle - %d мс (%s)", GetTickCount() - time, str);
  124.     str = "              любая        строка           для             теста              ";
  125.     time = GetTickCount();
  126.     for(new i = 0; i < 100000; i++) RemoveSpaces_MellikJKE(str);
  127.     printf("MellikJKE - %d мс (%s)", GetTickCount() - time, str);
  128.     str = "              любая        строка           для             теста              ";
  129.     time = GetTickCount();
  130.     for(new i = 0; i < 100000; i++) RemoveSpaces_regnaR(str);
  131.     printf("regnaR - %d мс (%s)", GetTickCount() - time, str);
  132.     str = "              любая        строка           для             теста              ";
  133.     time = GetTickCount();
  134.     for(new i = 0; i < 100000; i++) RemoveSpaces_DC(str);
  135.     printf("Daniel_Cortez - %d мс (%s)", GetTickCount() - time, str);
  136.     str = "              любая        строка           для             теста              ";
  137.     time = GetTickCount();
  138.     for(new i = 0; i < 100000; i++) RemoveSpaces_Denwer(str);
  139.     printf("Denwer - %d мс (%s)", GetTickCount() - time, str);
  140.     str = "              любая        строка           для             теста              ";
  141.     time = GetTickCount();
  142.     for(new i = 0; i < 100000; i++) RemoveSpaces_VT(str);
  143.     printf("Valera_Trefilov - %d мс (%s)", GetTickCount() - time, str);
  144.     str = "              любая        строка           для             теста              ";
  145.     time = GetTickCount();
  146.     for(new i = 0; i < 100000; i++) RemoveSpaces_ziggi(str);
  147.     printf("ziggi - %d мс (%s)", GetTickCount() - time, str);
  148.     str = "              любая        строка           для             теста              ";
  149.     time = GetTickCount();
  150.     for(new i = 0; i < 100000; i++) RemoveSpaces_g3o0or(str);
  151.     printf("g3o0or - %d мс (%s)", GetTickCount() - time, str);
  152.     str = "              любая        строка           для             теста              ";
  153.     time = GetTickCount();
  154.     for(new i = 0; i < 100000; i++) RemoveSpaces_polander(str);
  155.     printf("polander - %d мс (%s)", GetTickCount() - time, str);
  156.     str = "              любая        строка           для             теста              ";
  157.     time = GetTickCount();
  158.     for(new i = 0; i < 100000; i++) RemoveSpaces_Untonyst(str);
  159.     printf("Untonyst - %d мс (%s)", GetTickCount() - time, str);
  160.     str = "              любая        строка           для             теста              ";
  161.     time = GetTickCount();
  162.     for(new i = 0; i < 100000; i++) RemoveSpaces_iBorland(str);
  163.     printf("iBorland - %d мс (%s)", GetTickCount() - time, str);
  164.     str = "              любая        строка           для             теста              ";
  165.     time = GetTickCount();
  166.     for(new i = 0; i < 100000; i++) RemoveSpaces_Tracer(str);
  167.     printf("Tracer - %d мс (%s)", GetTickCount() - time, str);
  168.     str = "              любая        строка           для             теста              ";
  169.     time = GetTickCount();
  170.     for(new i = 0; i < 100000; i++) RemoveSpaces_ProG(str);
  171.     printf("ProG - %d мс (%s)", GetTickCount() - time, str);
  172.     str = "              любая        строка           для             теста              ";
  173.     time = GetTickCount();
  174.     for(new i = 0; i < 100000; i++) RemoveSpaces_KD(str);
  175.     printf("Kenny_Dalglish - %d мс (%s)", GetTickCount() - time, str);
  176.     str = "              любая        строка           для             теста              ";
  177.     time = GetTickCount();
  178.     for(new i = 0; i < 100000; i++) RemoveSpaces_ZL(str);
  179.     printf("Zaur_Lumanov - %d мс (%s)", GetTickCount() - time, str);
  180. */
  181. }
  182. stock RemoveSpaces_OK(string[])
  183. {
  184.     for(new i = strlen(string) - 1; i != -1; i--) if(string[i] == 32) strdel(string, i, i + 1);
  185. }
  186. stock RemoveSpaces_MellikJKE(String[])
  187. {
  188.     new i;
  189.     static ii;
  190.     for(ii = 0; String[ii] != '\0'; ii++)
  191.     {
  192.         switch(String[ii])
  193.         {
  194.             case ' ': continue;
  195.             default: String[i++] = String[ii];
  196.         }
  197.     }
  198.     String[i] = '\0';
  199. }
  200. stock RemoveSpaces_regnaR(string[])
  201. {
  202.     new i = strlen(string);
  203.     while( i >= 0 )
  204.     {
  205.         if(string[i] == ' ')
  206.         {
  207.             for(new j = i; j < strlen(string); j++)
  208.             {
  209.                 string[j] = string[j+1];
  210.             }
  211.         }
  212.         i--;
  213.     }
  214. }
  215. stock RemoveSpaces_DC(string[])
  216. {
  217.     static pos, pos2, c;
  218.     for (pos = 0, pos2 = 0;; ++pos)
  219.     {
  220.         c = string[pos];
  221.         switch (c)
  222.         {
  223.             case ' ': continue;
  224.             case '\0': break;
  225.         }
  226.         string[pos2++] = c;
  227.     }
  228.     string[pos2] = '\0';
  229. }
  230. stock RemoveSpaces_Denwer(string[])
  231. {
  232.     for( new i = 0x0; string[i] != 0x0; ++i ) if( string[i] == 0x20 ) strdel(string, i, i+1);
  233. }
  234. stock RemoveSpaces_VT(string[])
  235. {
  236.     for(new i=0; strfind(string," ") != -1; i++) strdel(string,strfind(string," "),strfind(string," ")+1);
  237. }
  238. stock RemoveSpaces_ziggi(string[])
  239. {
  240.     for (new i = 0, start = -1; string[i] != '\0'; i++) {
  241.         if (string[i] == ' ') {
  242.             if (start == -1) {
  243.                 start = i;
  244.             }
  245.         } else {
  246.             if (start != -1) {
  247.                 strdel(string, start, i);
  248.                 i -= start + 2;
  249.                 start = -1;
  250.             }
  251.         }
  252.     }
  253. }
  254. stock RemoveSpaces_g3o0or(string[])
  255. {
  256.     new write_pos;
  257.     for(new read_pos; string[read_pos] != '\0'; read_pos++)
  258.     {
  259.         if(string[read_pos] == ' ')
  260.         {
  261.             continue;
  262.         }
  263.         else
  264.         {
  265.             string[write_pos++] = string[read_pos];
  266.         }
  267.     }
  268.     string[write_pos] = '\0';
  269. }
  270. stock RemoveSpaces_polander(string[])
  271. {
  272.     new pos = strfind(string, " ");
  273.     while(pos != -1)
  274.     {
  275.         strdel(string, pos, pos+1);
  276.         pos = strfind(string, " ");
  277.     }
  278. }
  279. stock RemoveSpaces_Untonyst(string[])
  280. {
  281.     for(new i; string[i] != '\0'; i++)
  282.         if(string[i] == ' ')
  283.             strdel(string, i, i + 1), --i;
  284. }
  285. stock RemoveSpaces_iBorland(string[])
  286. {
  287.     for(new i = 0; strfind(string," ") != -1; i++)
  288.     {
  289.         strdel(string, strfind(string," "), strfind(string," ") + 1);
  290.     }
  291. }
  292. stock RemoveSpaces_Tracer(string[])
  293. {
  294.     for(new i, l = strlen(string); i < l; ++i)
  295.     {
  296.         if(string[i] != 32)continue;
  297.         strdel(string, i, i+1);
  298.     }
  299. }
  300. stock RemoveSpaces_ProG(string[])
  301. {
  302.     for( new i = 0; string[i]; )
  303.     {
  304.         if(string[i] == ' ') strdel(string, i, i + 1);
  305.         else i++;
  306.     }
  307. }
  308. stock RemoveSpaces_KD(input[])
  309. {
  310.     new pos, DelSymbol = ' ';
  311.     for(pos = strlen(input); input[pos] <= DelSymbol; ) pos--;
  312.     input[pos + 1] = EOS;
  313.     for(pos = 0; input[pos] <= DelSymbol; ) pos++;
  314.     strdel(input, 0, pos);
  315. }
  316. stock RemoveSpaces_ZL(string[])
  317. {
  318. new i, sp, buf[128];
  319. strcat(buf, string);
  320. for(i = 0; buf[i]; i++)
  321. {
  322. if (buf[i] == ' ') sp++;
  323. else string[i-sp] = buf[i];
  324. }
  325. string[i-sp] = '\0';
  326. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement