12.01.2013, 05:01
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.
and then you just follow the same steps for the sscanf method.
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
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);
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)
Source: https://sampwiki.blast.hk/wiki/Function:tickcount