Anti-Spam(strcmp vs udb_Hash)
#1

So, what do you think would be better in performance?
checking:
pawn Код:
if(udb_hash(text) == lasttext[playerid])


stock udb_hash(buf[])
{
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
or strcmp, the last text with the current one?
I know hashing would save a lot of memory, but i'm thinking of speed now.
If anyone could give me a benchmarking script for this issue, I would test it myself.

Edit:
I'm kicking only if the text repeats ~30 times, so the collisions don't really matter. Maybe this would do:
pawn Код:
stock small_hash(buf[])
{
    new int,len=strlen(buf);
    for(new i=0;i<len;i++) int+=buf[i];
    return int;
}
Reply


Messages In This Thread
Anti-Spam(strcmp vs udb_Hash) - by wups - 17.09.2011, 14:36
Re: Anti-Spam(strcmp vs udb_Hash) - by JaTochNietDan - 17.09.2011, 16:29
Re: Anti-Spam(strcmp vs udb_Hash) - by KoczkaHUN - 03.10.2011, 17:44

Forum Jump:


Users browsing this thread: 1 Guest(s)