03.02.2012, 21:30
(
Last edited by Zeex_; 04/02/2012 at 11:04 AM.
)
Hi,
As you probably know I am the author of the profiler plugin:
https://sampforum.blast.hk/showthread.php?tid=271129
Recently I started experimenting with #emit and made a Pawn-based profiler which does not require any plugins. It is very simple and is only able to profile public functions (in contrast to the plugin). Also it is less accurate than the plugin since it uses GetTickCount() to measure time which is millisecond resolution.
It provides these two functions:
ProfilerInit()
Initialize the profiler. This will redirect all public function calls to profiler's internal helpers by modifying the addresses stored in publics table.
ProfilerWriteData(const filename[])
Output results to a text file. This functions returns false if failed to open the file and true otherwise.
The output file looks like this:
Here Self Time is the overall execution time and Total Time is equal to Self Time + Total Time of all callees. The times are in milliseconds.
Also there are two definitions which you need to know about:
PROF_MAX_PUBLICS
The maximum number of public functions. Should be around the number of publics in your script or greater. If it's not large enough you will notice a warning message in the server log.
PROF_MAX_CALL_STACK
The maximum depth of profiler's call stack. This is where information about active public calls is stored. The default value of 10 should be enough but if you have something like recursive CallLocal/RemoteFunction calls you probably want to increase it.
Download
Note: profiler.inc depends on other includes which can be downloaded from the same link (see above).
As you probably know I am the author of the profiler plugin:
https://sampforum.blast.hk/showthread.php?tid=271129
Recently I started experimenting with #emit and made a Pawn-based profiler which does not require any plugins. It is very simple and is only able to profile public functions (in contrast to the plugin). Also it is less accurate than the plugin since it uses GetTickCount() to measure time which is millisecond resolution.
It provides these two functions:
ProfilerInit()
Initialize the profiler. This will redirect all public function calls to profiler's internal helpers by modifying the addresses stored in publics table.
ProfilerWriteData(const filename[])
Output results to a text file. This functions returns false if failed to open the file and true otherwise.
The output file looks like this:
Code:
+----------------------------------+----------------+----------------+----------------+ | Name | Calls | Self Time | Total Time | +----------------------------------+----------------+----------------+----------------+ | OnGameModeExit | 0 | 0 | 0 | +----------------------------------+----------------+----------------+----------------+ | OnPlayerConnect | 6 | 2 | 12 | +----------------------------------+----------------+----------------+----------------+ | OnPlayerDisconnect | 0 | 0 | 0 | +----------------------------------+----------------+----------------+----------------+ | OnPlayerRequestClass | 6 | 0 | 0 | +----------------------------------+----------------+----------------+----------------+ | some_function_1 | 6 | 4 | 10 | +----------------------------------+----------------+----------------+----------------+ | some_function_2 | 6 | 6 | 6 | +----------------------------------+----------------+----------------+----------------+
Also there are two definitions which you need to know about:
PROF_MAX_PUBLICS
The maximum number of public functions. Should be around the number of publics in your script or greater. If it's not large enough you will notice a warning message in the server log.
PROF_MAX_CALL_STACK
The maximum depth of profiler's call stack. This is where information about active public calls is stored. The default value of 10 should be enough but if you have something like recursive CallLocal/RemoteFunction calls you probably want to increase it.
Download
Note: profiler.inc depends on other includes which can be downloaded from the same link (see above).