Which is more faster?
#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


Messages In This Thread
Which is more faster? - by Fernado Samuel - 11.01.2013, 01:43
Re: Which is more faster? - by ReneG - 11.01.2013, 02:58
Re: Which is more faster? - by Fernado Samuel - 11.01.2013, 08:16
Re: Which is more faster? - by Fernado Samuel - 11.01.2013, 13:17
Re: Which is more faster? - by [KHK]Khalid - 11.01.2013, 14:50
Re: Which is more faster? - by Fernado Samuel - 12.01.2013, 01:00
Re: Which is more faster? - by ReneG - 12.01.2013, 05:01
Re: Which is more faster? - by Fernado Samuel - 12.01.2013, 15:44
Re: Which is more faster? - by Fernado Samuel - 13.01.2013, 18:11
Re: Which is more faster? - by Fernado Samuel - 13.01.2013, 20:36

Forum Jump:


Users browsing this thread: 9 Guest(s)