SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Thread Tools Display Modes
Old 23/07/2011, 03:50 AM   #1
Posts: n/a
Default 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

Last edited by dugi; 21/06/2016 at 02:17 PM.
  Reply With Quote
Old 23/07/2011, 04:03 AM   #2
Lorenc_'s Avatar
Join Date: Jan 2010
Location: Australia
Posts: 3,793
Reputation: 1179
Default Re: Performance profiler

This is sweet, I'll be trying this out now, thanks mate
Join the best Cops And Robbers in SA-MP, today.

Lorenc_ is offline   Reply With Quote
Old 23/07/2011, 05:38 AM   #3
Kyosaur's Avatar
Join Date: Mar 2008
Location: USA - California
Posts: 973
Reputation: 349
Default Re: Performance profiler

This is pretty neat, thanks for releasing it (gonna dive into the source *drool*).
Kyosaur is offline   Reply With Quote
Old 23/07/2011, 07:09 AM   #4
Join Date: Nov 2008
Location: England
Posts: 1,843
Reputation: 52
Default Re: Performance profiler

Awesome plugin. Will take a better look when I get home.
Burridge is offline   Reply With Quote
Old 23/07/2011, 08:57 AM   #5
RyDeR`'s Avatar
Join Date: Feb 2009
Location: Belgium
Posts: 2,929
Reputation: 703
Default Re: Performance profiler

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

RyDeR` is offline   Reply With Quote
Old 23/07/2011, 09:11 AM   #6
leong124's Avatar
Join Date: Jun 2008
Location: Hong Kong, China
Posts: 1,496
Reputation: 134
Default 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...

Sorry for my bad English and my weakness in expressing myself.
leong124 is offline   Reply With Quote
Old 23/07/2011, 09:18 AM   #7
Join Date: Jan 2009
Posts: 6,129
Reputation: 1127
Default Re: Performance profiler

Brilliant, thank you. I'll certainly make good use of this in the near future.
Calgon is offline   Reply With Quote
Old 23/07/2011, 09:32 AM   #8
QuaTTrO's Avatar
Join Date: Aug 2009
Posts: 516
Reputation: 75
Default Re: Performance profiler

Dont work in my gamemode its crashing server... ;/
QuaTTrO is offline   Reply With Quote
Old 23/07/2011, 10:04 AM   #9
Mauzen's Avatar
Join Date: Jun 2007
Location: Western Germany
Posts: 4,878
Reputation: 1597
Default 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.
Mauzen is offline   Reply With Quote
Old 23/07/2011, 10:42 AM   #10
Posts: n/a
Default Re: Performance profiler

Ah! I haven't mention anywhere: the script you're profiling must have debug symbols in it i.e. compiled with either -d3 or -d2 flag.

Sorry I should have said this in the first post. I will upload an update soon to fix that.
  Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Timers performance Zamaroht Scripting Help 5 30/08/2012 09:29 AM
Bad performance on a great PC Juan Dover Client Support 20 13/02/2011 07:34 PM
Performance issues gamer931215 Everything and Nothing 3 26/08/2010 09:54 PM
SQL performance Dabombber Help Archive 7 24/09/2009 03:49 PM
9400 GT - GTA:SA Performance rafay Everything and Nothing 14 09/06/2009 04:23 PM

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

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