SA-MP Forums

SA-MP Forums (
-   Plugin Development (
-   -   [Plugin] Performance profiler (

0x5A656578 23/07/2011 03:50 AM

Performance profiler
Performance profiler

This plugin can count how many times each of functions is called and how much time it takes to execute. This information is outputted in one of the currently supported formats: HTML , XML or and plain text.

Profiling begins right after a script gets loaded and stops when you unload it (i.e. when you close the server or do gmx/fsunload/fsreload). At unloading time, all statistical data is saved to a file called <script_name>-profile.<format> in .amx directory. The <format> part depends on your output format choice (see below).

Profiler adds a few extra server.cfg variables:
  • profile_gamemode <0|1>

    If set to 1, profiler will profile currently running game mode. Default value is 0.

  • profile_filterscripts <fs1> <fs2> ...

    A list of filter scripts to be profiled. Can be empty.

  • profile_format <xml|html|txt>

    Set statistics output format. Default is html. Note for HTML: it is possible to sort stats by clicking on column names!!

  • call_graph <0|1>

    Set this option to 1 if you want profiler to generate a call graph. The graph is generated as a GraphViz dot file.

  • call_graph_format <format>

    If specified, profiler will try to convert the .gv file into one of the formats supported by dot.

    The dot program is invoked as follows:


    <install_path>/dot -T<format> <some_script-calls.gv> -O
    On Windows, install_path is looked up in registry first, then in GV_HOME environment variable (as on *nix). If GraphViz install path is not found it is assumed to be already in PATH.


Source code

Lorenc_ 23/07/2011 04:03 AM

Re: Performance profiler
This is sweet, I'll be trying this out now, thanks mate :D

0x5A656578 23/07/2011 04:20 AM

Re: Performance profiler

Originally Posted by SPAWN_METAL (Post 1306417)

It's very cool plugin but not work with my gamemode =(
May plugins create this bug?

Hmm try updating crashdetect or don't load it

Kyosaur 23/07/2011 05:38 AM

Re: Performance profiler
This is pretty neat, thanks for releasing it (gonna dive into the source *drool*).

Burridge 23/07/2011 07:09 AM

Re: Performance profiler
Awesome plugin. Will take a better look when I get home.

RyDeR` 23/07/2011 08:57 AM

Re: Performance profiler
Very nice and advanced plugins you release in here. I really like it, good job.

leong124 23/07/2011 09:11 AM

Re: Performance profiler
When I do this in OnGameModeExit the server crashes when I close the server/ change the gamemode:
pawn Code:
crashdetect says that it is crashed by Profiler_PrintStats.
It is still crashing without the crashdetect plugin.

I put
pawn Code:
in OnGameModeInit.

I'm not sure if I used it wrongly...

Calgon 23/07/2011 09:18 AM

Re: Performance profiler
Brilliant, thank you. I'll certainly make good use of this in the near future.

QuaTTrO 23/07/2011 09:32 AM

Re: Performance profiler
Dont work in my gamemode its crashing server... ;/

Mauzen 23/07/2011 10:04 AM

Re: Performance profiler
Sounds nice, but also doesnt work for me. When stopping and saving on gamemode exit, nothing happens. If I stop and save with a command only the file with the header is created, but it shows no functions, and the server crashes. (windows version, R1 server)
Would be great if this really works, as i am doing a lot of optimizing work atm, so this would be really handy.

All times are GMT. The time now is 10:22 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.