SA-MP Forums Archive
Debug level and different speed - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Debug level and different speed (/showthread.php?tid=487228)



Debug level and different speed - Igorek - 12.01.2014

Hello all.

I compiled fs at different debug level and made ​​speed test.

There are 2 functions (prototypes):
stock Games_trim2(str[], Char = ' ');
stock Games_trimE(str[], Char = ' ');

Each function does the same thing - cuts the sign from the start and end of the line.
As and a standard function trim() in many programming languages.

-------------
At every debug level - different function wins in speed.

Results:
PHP код:
//d0
[15:24:05] - Games_trim2(): 4995 (ms)
[
15:24:11] - Games_trimE(): 5364 (ms)
[
15:24:11] - Games_trim2(): 787 (ms)
[
15:24:12] - Games_trimE(): 903 (ms)
//d3
[15:27:53] - Games_trim2(): 9057 (ms)
[
15:27:58] - Games_trimE(): 5086 (ms)
[
15:27:59] - Games_trim2(): 1048 (ms)
[
15:28:00] - Games_trimE(): 865 (ms
PHP код:
#include <a_samp>
public OnFilterScriptInit()
{
    new 
time GetTickCount();
    for(new 
i1000000i++) {
        new 
str[] ="+++++++++++++++++++++++++++++++++++++++string++++++++++++++++++++++++++++++++++++++++++";
        
Games_trim2(str'+');
    }
    
printf("- Games_trim2(): %i (ms)"GetTickCount()-time);
    
time GetTickCount();
    for(new 
i1000000i++) {
        new 
str[] = "+++++++++++++++++++++++++++++++++++++++string++++++++++++++++++++++++++++++++++++++++++";
        
Games_trimE(str'+');
    }
    
printf("- Games_trimE(): %i (ms)\n\n"GetTickCount()-time);
    
time GetTickCount();
    for(new 
i1000000i++) {
        new 
str[] = "+string+";
        
Games_trim2(str'+');
    }
    
printf("- Games_trim2(): %i (ms)"GetTickCount()-time);
    
time GetTickCount();
    for(new 
i1000000i++) {
        new 
str[] = "+string+";
        
Games_trimE(str'+');
    }
    
printf("- Games_trimE(): %i (ms)\n\n"GetTickCount()-time);
}
stock Games_trim2(str[], Char ' ')
{
    new 
i;
    while(
str[i] == Chari++;
    
strdel(str0i);
    if(!
i) return 1;
    
strlen(str) - 1;
    while(
str[i] == Chari--;
    
str[1] = '\0';
    return 
1;
}
Games_trimE(str[], Char ' '){
    new 
= -1;
    while(
str[++i] == Char){}
    
strdel(str0i);
    if(!
i) return ;
    
strlen(str);
    while(
str[--i] == Char){}
    
str[++i] = '\0';
    return ;

When debug level 0 wins function Games_trim2, and when debug level 3 - Games_trimE.

Why is this happening?
And what kind debug level you recommend?


Re: Debug level and different speed - Igorek - 13.01.2014

No one knows anything?


Re: Debug level and different speed - Igorek - 15.01.2014

No one knows anything? [2]


Re: Debug level and different speed - Igorek - 15.01.2014

No one knows anything? [3]


Re: Debug level and different speed - Igorek - 16.01.2014

No one knows anything? [4]


Re: Debug level and different speed - Seregamil1 - 26.01.2014

No one knows anything? [5]


Re: Debug level and different speed - Igorek - 28.01.2014

No one knows anything? [6]


Re: Debug level and different speed - SerieWoordenaar - 28.01.2014

If you want the answer look at the assembly.


Re: Debug level and different speed - Seregamil1 - 25.08.2014

No one knows anything? [7]