Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Support [Server] Script performance testing

 
  • 0 Vote(s) - 0 Average
Server Script performance testing
kalEd
Offline

Burgershot Member
Posts: 7
Threads: 3
Joined: Mar 2021
Reputation: 0
#1
2021-03-08, 10:02 AM
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.
Radical
Offline

Burgershot Member
Posts: 148
Threads: 21
Joined: Dec 2020
Reputation: 16
#2
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;
} 
Virsenas
Offline

Burgershot Member
Posts: 47
Threads: 0
Joined: Feb 2021
Reputation: 6
#3
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);
kalEd
Offline

Burgershot Member
Posts: 7
Threads: 3
Joined: Mar 2021
Reputation: 0
#4
2021-03-08, 01:30 PM
thanks
Kwarde
Offline

Burgershot Member
Posts: 99
Threads: 2
Joined: Sep 2020
Reputation: 8
Location: The Netherlands
#5
2021-03-08, 07:04 PM
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
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#6
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.
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode