Debug level and different speed
#1

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?
Reply
#2

No one knows anything?
Reply
#3

No one knows anything? [2]
Reply
#4

No one knows anything? [3]
Reply
#5

No one knows anything? [4]
Reply
#6

No one knows anything? [5]
Reply
#7

No one knows anything? [6]
Reply
#8

If you want the answer look at the assembly.
Reply
#9

No one knows anything? [7]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)