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.
|
[Server] Script performance testing
|
|
2021-03-08, 11:26 AM
PHP Code: public OnPlayerConnect(playerid)
{
? ? new count = GetTickCount();
? ? //Rest of OnPlayerConnect
? ? printf("Time taken to execute OnPlayerConnect: %d", GetTickCount() - count);
? ? return 1;
}
2021-03-08, 12:35 PM
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);
2021-03-08, 01:30 PM
thanks
2021-03-08, 07:04 PM
You also may want to read this (and use y_profiling): https://github.com/pawn-lang/YSI-Include...eatures.md
2021-03-08, 07:59 PM
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.
|

