[Tutorial] Speed Testing
#1

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!
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=218491
Reply
#3

Quote:
Originally Posted by Djole1337
Посмотреть сообщение
This is the simpler way to do it, as that is pretty advanced.
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)