Advertisement
Guest User

Untitled

a guest
Feb 26th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.62 KB | None | 0 0
  1. main()
  2. {
  3.     new
  4.         test[] = #Bonjour,
  5.         t = GetTickCount();
  6.    
  7.     for(new i; i < 100000000; i++)
  8.         strlen_papawy(test);
  9.    
  10.     printf("strlen_papawy : %d ('%s' comporte %d caracteres)", GetTickCount()-t, test, strlen_papawy(test));
  11.    
  12.     t = GetTickCount();
  13.    
  14.     for(new i; i < 100000000; i++)
  15.         strlen_satek(test);
  16.    
  17.     printf("strlen_satek : %d ('%s' comporte %d caracteres)", GetTickCount()-t, test, strlen_satek(test));
  18.    
  19.     t = GetTickCount();
  20.    
  21.     for(new i; i < 100000000; i++)
  22.         strlen_dth(test);
  23.        
  24.     printf("strlen_dth : %d ('%s' comporte %d caracteres)", GetTickCount()-t, test, strlen_dth(test));
  25.    
  26.     t = GetTickCount();
  27.    
  28.     for(new i; i < 100000000; i++)
  29.         strlen_dth2(test);
  30.        
  31.     printf("strlen_dth2 : %d ('%s' comporte %d caracteres)", GetTickCount()-t, test, strlen_dth2(test));   
  32.    
  33.     t = GetTickCount();
  34.    
  35.     for(new i; i < 100000000; i++)
  36.         strlen_dth3(test);
  37.        
  38.     printf("strlen_dth3 : %d ('%s' comporte %d caracteres)", GetTickCount()-t, test, strlen_dth3(test));       
  39. }
  40.  
  41. strlen_papawy(str[], size=sizeof(str))
  42. {
  43.     new i;
  44.     for(i=0; i<size;++i)
  45.     {
  46.         if(str[i] == EOS)
  47.             break;
  48.     }
  49.     return i;
  50. }  
  51.  
  52. strlen_satek(const str[])
  53. {
  54.       new idx;
  55.       while(str[idx++] != EOS) {}
  56.       return idx;
  57. }  
  58.  
  59. strlen_dth(const string[])
  60. {
  61.     new
  62.         c;
  63.          
  64.     for(;;c++)
  65.         if(string[c] == EOS)  
  66.             break;
  67.      
  68.     return c;
  69. }  
  70.  
  71. strlen_dth2(const string[])
  72. {
  73.     new
  74.         i;
  75.  
  76.     while(string[i] != EOS) i++;
  77.    
  78.     return i;
  79. }
  80.  
  81. strlen_dth3(const string[])
  82. {
  83.     new
  84.         c;
  85.          
  86.     for(; string[c] != EOS ; c++) {}
  87.      
  88.     return c;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement