Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- public OnFilterScriptInit()
- {
- new a, b, i, var, set, get;
- set = get = 0;
- /* Konstantinos */
- // Set
- a = GetTickCount();
- for(i = 0; i < 100000; i++) SetCombination(var, 0, 0);
- b = GetTickCount();
- set += b - a;
- a = GetTickCount();
- for(i = 0; i < 100000; i++) SetCombination(var, 0, 0);
- b = GetTickCount();
- set += b - a;
- a = GetTickCount();
- for(i = 0; i < 100000; i++) SetCombination(var, 0, 0);
- b = GetTickCount();
- set += b - a;
- printf("* [Set] Konstantinos - %i ms", set / 3);
- // Get
- a = GetTickCount();
- for(i = 0; i < 100000; i++) GetCombination(var, 0);
- b = GetTickCount();
- get += b - a;
- a = GetTickCount();
- for(i = 0; i < 100000; i++) GetCombination(var, 0);
- b = GetTickCount();
- get += b - a;
- a = GetTickCount();
- for(i = 0; i < 100000; i++) GetCombination(var, 0);
- b = GetTickCount();
- get += b - a;
- printf("* [Get] Konstantinos - %i ms", get / 3);
- /* Swedky */
- set = get = 0;
- // Set
- a = GetTickCount();
- for(i = 0; i < 100000; i++) SetCombination2(var, 0, 0);
- b = GetTickCount();
- set += b - a;
- a = GetTickCount();
- for(i = 0; i < 100000; i++) SetCombination2(var, 0, 0);
- b = GetTickCount();
- set += b - a;
- a = GetTickCount();
- for(i = 0; i < 100000; i++) SetCombination2(var, 0, 0);
- b = GetTickCount();
- set += b - a;
- printf("* [Set] Swedky - %i ms", set / 3);
- // Get
- a = GetTickCount();
- for(i = 0; i < 100000; i++) GetCombination2(var, 0);
- b = GetTickCount();
- get += b - a;
- a = GetTickCount();
- for(i = 0; i < 100000; i++) GetCombination2(var, 0);
- b = GetTickCount();
- get += b - a;
- a = GetTickCount();
- for(i = 0; i < 100000; i++) GetCombination2(var, 0);
- b = GetTickCount();
- get += b - a;
- printf("* [Get] Swedky - %i ms", get / 3);
- return 1;
- }
- stock SetCombination(&var, slot, value)
- {
- new comb[11];
- format(comb, 11, "%010i", var);
- comb[9 - slot] = (1 <= value <= 9) ? 48 + value : 48;
- var = strval(comb);
- return 1;
- }
- stock GetCombination(var, slot)
- {
- new comb[11];
- format(comb, 11, "%010i", var);
- if(48 <= (slot = comb[9 - slot]) <= 57) return slot - 48;
- return 0;
- }
- stock SetCombination2(&var, slot, value) // ~0.0035 ms
- {
- new comb[11];
- format(comb, 11, "%010i", var);
- switch(value)
- {
- case 1: comb[9 - slot] = '1';
- case 2: comb[9 - slot] = '2';
- case 3: comb[9 - slot] = '3';
- case 4: comb[9 - slot] = '4';
- case 5: comb[9 - slot] = '5';
- case 6: comb[9 - slot] = '6';
- case 7: comb[9 - slot] = '7';
- case 8: comb[9 - slot] = '8';
- case 9: comb[9 - slot] = '9';
- default: comb[9 - slot] = '0';
- }
- var = strval(comb);
- return 1;
- }
- stock GetCombination2(var, slot) // ~0.002 ms
- {
- new comb[11];
- format(comb, 11, "%010i", var);
- switch(comb[9 - slot])
- {
- case '0': return 0;
- case '1': return 1;
- case '2': return 2;
- case '3': return 3;
- case '4': return 4;
- case '5': return 5;
- case '6': return 6;
- case '7': return 7;
- case '8': return 8;
- case '9': return 9;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement