Thursday, October 18, 2012

Script Analyzer

Script Analyzer

Hi,

This filterscript allows people to analyze their script by shoving a copy of the script into the scriptfiles folder and then typing 'analyze scriptname' into the server console.

This script analyzer currently counts:
- Includes
- Defines
- Objects
- Pickups
- Textdraws
- 3D Text Labels
- Enumerators
- Float variables
- How many times SendClientMessage was used
- How many times SendClientMessageToAll was used
- How many times format was used
- How many times sizeof was used
- For loops
- While loops
- If statements
- How many times SetTimer was used
- How many times SetTimerEx was used
- Functions
- Callbacks
- All variables
- Strings
- Memory usage

You should only run the script analyzer on a home host or a testing server, because it slows the server down for a while (during an analysis, that is).

Usage:
To use this filterscript, simply compile it (an .amx is provided in the download, you can drag that into the filterscripts folder) and then type:

Code:
loadfs analyzer
Into the console.

Before running the analyzer, put a copy of the script (.pwn file) you wish to analyze into the scriptfiles folder, and then type the following in the console:

Code:
analyze scriptname.pwn
The analysis should start.

Example:
Code:
-----------------------------------
- Beginning analysis for IG-RP.pwn...
- Lines: 83346, Size: 4012 kb

- Your script uses the following includes:
  + a_samp.inc
  + dini.inc
  + utils.inc
  + zones.inc
  + yom_buttons.inc
  + streamer.inc
  + cuff.inc
  + foreach.inc
  + SII.inc

- Your script has 286 #defines.
- Your script is set to use 50000 bytes of memory.
- Your script has 10277 objects and 230 pickups.
- Your script uses SendClientMessage 5825 times.
- Your script uses SendClientMessageToAll 120 times.
- Your script uses the format function 3553 times.
- Your script uses the sizeof operator 3596 times.
- Your script has 77 textdraws.
- Your script has 126 3D text labels.
- Your script has 33 enumeration arrays.
- Your script has 487 float variables.
- Your script has 290 for loops.
- Your script has 171 while loops.
- Your script has 10705 if statements.
- Your script uses SetTimer 38 times.
- Your script uses SetTimerEx 47 times.
- Your script has 131 functions.
- Your script has 219 callbacks.
- Your script has 3014 variables.
- Your script uses 127847 cells in total for strings.
- Your script has 2358 strings, which adds up to 511388 bytes of memory.

Analysis took 4838 ms to complete.
-----------------------------------
NOTE: This script does NOT count commented lines, so if you have something like this:

PHP Code:
#define money 500 // a comment 
That line will be counted as a define. The comment at the end is ignored, but if you do this:

PHP Code:
// #define money 500 // a comment 
The above line will NOT be counted as a define, neither will:

PHP Code:
//#define money 500 // a comment 
Or:

PHP Code:
/*#define money 500*/ // a comment 
Or:

PHP Code:
if (condition)
{
    
//new test;
Or:

PHP Code:
// NONE OF THE BELOW LINES ARE COUNTED.
//#include <hi>
/* #include <lol> */
// #include <sup> 
It also counts functions like this:

PHP Code:
CreateDynamicObject (40000.00.00.00.00.00.0) sizeof test
CreatePickup       
(12390.00.00.00.00.00.0); 
Accuracy:
Analyzing this code:

Code:
#include <a_samp>
// #include <a_http>

#define DEFINE_1 50
#define DEFINE_2 40
#define DEFINE_3 30
#define DEFINE_4 20
#define DEFINE_5 10
//#define DEFINE_6 5

new stock string[256];
new stock text[128];
//new ip[16];

stock test()
{
}

The following results:

Code:
-----------------------------------
- Beginning analysis for test.pwn...
- Lines: 17, Size: 1 kb

- Your script uses the following includes:
  + a_samp.inc

- Your script has 5 #defines.
- Your script has 0 objects and 0 pickups.
- Your script uses SendClientMessage 0 times.
- Your script uses SendClientMessageToAll 0 times.
- Your script uses the format function 0 times.
- Your script uses the sizeof operator 0 times.
- Your script has 0 textdraws.
- Your script has 0 3D text labels.
- Your script has 0 enumeration arrays.
- Your script has 0 float variables.
- Your script has 0 for loops.
- Your script has 0 while loops.
- Your script has 0 if statements.
- Your script uses SetTimer 0 times.
- Your script uses SetTimerEx 0 times.
- Your script has 1 functions.
- Your script has 0 callbacks.
- Your script has 2 variables.
- Your script uses 384 cells in total for strings.
- Your script has 2 strings, which adds up to 1536 bytes of memory.
 
Analysis took 3 ms to complete.
-----------------------------------
Include:
There is also a stand-alone include that comes with this filterscript.

You can use Analyze(scriptname) to analyze a whole script, or AnalyzeEx(scriptname, phrase) to analyze a single phrase in a script.

http://www.solidfiles.com/d/0c6af5987a/
http://pastebin.com/FLvxAakm

No comments:

Post a Comment