Which is more faster?
#1

Removed, thanks for the help!
Reply
#2

Quote:
Originally Posted by Fernado Samuel
View Post
Player data should load from the database once they login, so that which one is more faster?

pawn Code:
sscanf(Query, "p<|>s[24]s[128]iiiiiiiiiiii",bla, bla, bla....);
OR

pawn Code:
format(query,sizeof(query),"SELECT * FROM `playerdata` WHERE `user`='%s'",pname);
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(savingstring, "score"); SetPlayerScore(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "money"); MoneyGiven[playerid] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "kills"); PlayerInfo[playerid][Kills] = strval(savingstring);
       //etc....
 }
Can anyone please tell me?
Why don't you just benchmark it?
Reply
#3

Removed
Reply
#4

Help
Reply
#5

Quote:
Originally Posted by Fernado Samuel
View Post
What is benchmark ? i didn't understand.
https://sampforum.blast.hk/showthread.php?tid=218491.
Reply
#6

Removed
Reply
#7

The main concept of benchmarking is getting the time before code executes, running the code, then getting the time after the code finishes executing. The difference of the start time v.s the current time is approximately how long the code took to execute. It's basic math.
pawn Code:
format(query,sizeof(query),"SELECT * FROM `playerdata` WHERE `user`='%s'",pname);

new tick = tickcount();

mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
    mysql_fetch_field_row(savingstring, "score"); SetPlayerScore(playerid, strval(savingstring));
    mysql_fetch_field_row(savingstring, "money"); MoneyGiven[playerid] = strval(savingstring);
    mysql_fetch_field_row(savingstring, "kills"); PlayerInfo[playerid][Kills] = strval(savingstring);
    //etc....
}

printf("mysql_fetch_field_row method executed in %dms", tickcount() - tick);
and then you just follow the same steps for the sscanf method.
pawn Code:
new tick = tickcount();

sscanf(Query, "p<|>s[24]s[128]iiiiiiiiiiii",bla, bla, bla....);

printf("sscanf method executed in approx. %dms", tickcount() - tick)
You can optimize this code a little bit as well (R7 capabilities, and an auto increment primary key, etc).

Source: https://sampwiki.blast.hk/wiki/Function:tickcount
Reply
#8

Removed, thanks for the help!
Reply
#9

Help...
Reply
#10

Removed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)