[Tutorial] Speed Testing - 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)
+---- Forum: Tutorials (
https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Speed Testing (
/showthread.php?tid=490858)
Speed Testing -
kooltuO - 28.01.2014
Speed Testing
Hello guys, I decided to write my first tutorial about Speed Testing in SA-MP for a while now and I decided to take off.
1 - Pages that might help
https://sampwiki.blast.hk/wiki/GetTickCount
https://sampwiki.blast.hk/wiki/Printf
2 - A first code.
To set up a speed test you need to use on of the 'public's' in your pawno, lets take a code to test.
pawn Код:
public OnGameModeInit()
{
LoadMap(); // Custom stock loading my maps.
SetGameModeText(TEXT_GAMEMODETEXT); // Setting the gamemode text to my defined gamemode name.
AddPlayerClass(0, 163.81, 4028.46, 4.06, 0.0, 0, 0,0,0,0,0); // Creating the class
EnableStuntBonusForAll(0); // Disabling Stunt Bonus
return 1;
}
now we have to set up the GetTickCount.
pawn Код:
public OnGameModeInit()
{
new OnGameModeInitCount = GetTickCount(); // creating the OnGameModeInit count.
LoadMap(); // Custom stock loading my maps.
SetGameModeText(TEXT_GAMEMODETEXT); // Setting the gamemode text to my defined gamemode name.
AddPlayerClass(0, 163.81, 4028.46, 4.06, 0.0, 0, 0,0,0,0,0); // Creating the class
EnableStuntBonusForAll(0); // Disabling Stunt Bonus
printf("Excecuted OnGameModeInit, time taken: %d", GetTickCount() - OnGameModeInitCount); // Printing the time which is taken.
return 1;
}
Now we have set up the GetTickCount function as well as the print, let me explain them in more details.
pawn Код:
new OnGameModeInitCount = GetTickCount();
this defines which tickcount the code has to run, why? A part of your script can include a few tick counts, and they could mess up when they have the same name.
pawn Код:
printf("Excecuted OnGameModeInit, time taken: %d", GetTickCount() - OnGameModeInitCount);
printf is a function to print things in your server logs with a string, the normal print function isn't able to hold strings.
pawn Код:
GetTickCount() - OnGameModeInitCount
This part writes which tickcount has to be called, this is the same reason as the defined part at the new, which is explained above.
3 - Outro
I hope you guys got helped a bit with this tutorial, it's my first tutorial so critism is always allowed, I'd love to learn from you too!
Re: Speed Testing -
Djole1337 - 28.01.2014
https://sampforum.blast.hk/showthread.php?tid=218491
Re: Speed Testing -
kooltuO - 28.01.2014
Quote:
Originally Posted by Djole1337
|
This is the simpler way to do it, as that is pretty advanced.
Re: Speed Testing -
iZN - 28.01.2014
Quote:
Originally Posted by kooltuO
This is the simpler way to do it, as that is pretty advanced.
|
How that is advance? Slice just made the macro look abit advance. It is VERY easy to benchmark with it and is accurate.