Which is more faster? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Which is more faster? (
/showthread.php?tid=406628)
Which is more faster? -
Fernado Samuel - 11.01.2013
Removed, thanks for the help!
Re: Which is more faster? -
ReneG - 11.01.2013
Quote:
Originally Posted by Fernado Samuel
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?
Re: Which is more faster? -
Fernado Samuel - 11.01.2013
Removed
Re: Which is more faster? -
Fernado Samuel - 11.01.2013
Help
Re: Which is more faster? -
[KHK]Khalid - 11.01.2013
Quote:
Originally Posted by Fernado Samuel
What is benchmark ? i didn't understand.
|
https://sampforum.blast.hk/showthread.php?tid=218491.
Re: Which is more faster? -
Fernado Samuel - 12.01.2013
Removed
Re: Which is more faster? -
ReneG - 12.01.2013
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
Re: Which is more faster? -
Fernado Samuel - 12.01.2013
Removed, thanks for the help!
Re: Which is more faster? -
Fernado Samuel - 13.01.2013
Help...
Re: Which is more faster? -
Fernado Samuel - 13.01.2013
Removed