[Include] y_stringhash - Fast string comparisons.
#3

This is even slower then using strcmp...
Код:
Comparing a string 1000 times in a row using switch().
Loop finished after: 6 milliseconds.
..
Comparing a string 1000 times in a row using strcmp.
Loop finished after: 2 milliseconds.
Код:
Comparing a string 100,000 times in a row using switch().
Loop finished after: 330 milliseconds.
..
Comparing a string 100,000 times in a row using strcmp.
Loop finished after: 134 milliseconds.
Код:
Comparing a string 500,000 times in a row using switch().
Loop finished after: 1636 milliseconds.
..
Comparing a string 500,000 times in a row using strcmp.
Loop finished after: 664 milliseconds.
Code used:
PHP код:
#include <a_samp>
#include <YSI\y_stringhash>
main() {
    
printf("Comparing a string 1000 times in a row using switch().");
    new 
count GetTickCount();
    for(new 
01001i++) {
        new 
string[144];
        
format(string144"something random (%i)"random(10000));
        switch(
YHash(string)) {
            case 
_H<dfsd>: {
                print(
"waow");
            }
            case 
_H<fghfggfhgf>: {
                print(
"waow");
            }
            case 
_H<fghfsdfsdfggfhgf>: {
                print(
"waow");
            }
        }
    }
    
printf("Loop finished after: %i milliseconds."GetTickCount()-count);
    print(
"..");
    
printf("Comparing a string 1000 times in a row using strcmp.");
    
count GetTickCount();
    for(new 
01001i++) {
        new 
string[144];
        
format(string144"something random (%i)"random(10000));
        if(!
strcmp(string"dfsd")) {
            print(
"waow");
        }
        else if(!
strcmp(string"fghfggfhgf")) {
            print(
"waow");
        }
        else if(!
strcmp(string"fghfsdfsdfggfhgf")) {
            print(
"waow");
        }
    }
    
printf("Loop finished after: %i milliseconds."GetTickCount()-count);

(Sorry if I missunderstod this include.)
Reply


Messages In This Thread
y_stringhash - Fast string comparisons. - by corne - 17.04.2015, 19:17
Re: y_stringhash - Fast string comparisons. - by Kaperstone - 12.07.2017, 22:21
Re: y_stringhash - Fast string comparisons. - by Meller - 12.07.2017, 22:29
Re: y_stringhash - Fast string comparisons. - by xMoBi - 13.07.2017, 09:36
Re: y_stringhash - Fast string comparisons. - by Dayrion - 15.07.2017, 19:06
Re: y_stringhash - Fast string comparisons. - by PT - 15.07.2017, 22:54
Re: y_stringhash - Fast string comparisons. - by Astralis - 15.07.2017, 23:14
Re: y_stringhash - Fast string comparisons. - by Riddick94 - 16.07.2017, 15:43
Re: y_stringhash - Fast string comparisons. - by Kaperstone - 16.07.2017, 16:06
Re: y_stringhash - Fast string comparisons. - by Y_Less - 16.07.2017, 18:47
Re: y_stringhash - Fast string comparisons. - by Riddick94 - 18.07.2017, 18:06

Forum Jump:


Users browsing this thread: 1 Guest(s)