Burgershot
[Server] Script performance testing - Printable Version

+- Burgershot (https://www.burgershot.gg)
+-- Forum: SA-MP (https://www.burgershot.gg/forumdisplay.php?fid=3)
+--- Forum: Support (https://www.burgershot.gg/forumdisplay.php?fid=12)
+--- Thread: [Server] Script performance testing (/showthread.php?tid=1741)



Script performance testing - kalEd - 2021-03-08

How can I detect how fast a function is running using gettickcount? If anyone can give me an example, or if you know another method.


RE: Script performance testing - Radical - 2021-03-08

PHP Code:
public OnPlayerConnect(playerid)
{
    new count GetTickCount();
    //Rest of OnPlayerConnect
    printf("Time taken to execute OnPlayerConnect: %d"GetTickCount() - count);
    return 1;




RE: Script performance testing - Virsenas - 2021-03-08

You just get the tick count at the start of your code and at the end where it is supposed to stop.


Code:
new tickcountstart,tickcountend;
tickcountstart=GetTickCount();
printf("Start: %d",tickcountstart);

CreateDynamicObject(...);
CreateDynamicObject(...);
CreateDynamicObject(...);
CreateDynamicObject(...);
CreateDynamicObject(...);

tickcountend=GetTickCount();
printf("End: %d",tickcountend);
printf("Difference: %d - %d = %d",tickcountend, tickcountstart, tickcountend-tickcountstart);



RE: Script performance testing - kalEd - 2021-03-08

thanks


RE: Script performance testing - Kwarde - 2021-03-08

You also may want to read this (and use y_profiling): https://github.com/pawn-lang/YSI-Includes/blob/5.x/YSI_Core/y_profiling/features.md


RE: Script performance testing - Y_Less - 2021-03-08

Using GetTickCount is not the right way to do this at all. It only tells you how long a single piece of code might take to run (and very very very inaccurately). It won't tell you which parts are actually slow, nor which parts are run a lot. You need the profiler plugin.