Welcome to The Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads

G Profiler - Garry's Mod Lua Profiler


Recommended Posts

Since I dread working with lua, i've been sticking with c as much as I can.

I've finished the basics for the Garry's Mod profiling tool i've been working on. In it's current state, it only assesses the execution time of the profiled block of code, but memory profiling is in progress.

 

Please Read:

GProfiler is designed to be as fast as possible so it can be used for development, and on a deployed server. That means no automatic function identification.

 

Current Features (lua profiler):

- Written as a GLoader cartridge in c++ with gstdlib, you will need gloader installed on your server to install this.

- Can time any block of code with the use of the in script profiling calls.

- Uses a hash table to allow for the use of string identifiers without any serious performance hit.

- Exports all profiles as binary files in the 'profiles' folder in your server directory

 

Current Features (console tool):

- Loads profiles from the profiles folder when given the path.

- Reads the sample data from each profile and calculates basic statistics such as average execution time, minimum execution time, and maximum execution time.

- Ability to export the statistical data to a text file.

- Ability to export the statistical data to a csv file (to import into excell).

 

Using G Profiler:

1. Install the latest version of GLoader:

- Download the dll here.

- Place the .dll in your server folder in garrysmod/lua/bin/

- Load the .dll when the server starts by adding a file called "sv_gloader_init.lua" to garrysmod/lua/autorun/server, and put this code inside (without quotes) "local gloader = require("gloader")".

- Start the dedicated server, and be sure you see the GLoader message in the server console.

 

2. Install the GProfiler cartridge:

- Download the latest version of GProfiler here.

- Copy the .ctg file to the "cartridges" folder created by gloader when you ran the server. It should be in the same directory as the server executable.

- All done, GLoader will automatically load and initialize the cartridge when the server starts!

 

3. Profile some code:

- You can use a test profiling script that can be found here. The code is well documented, and should explain how the GProfiler works.

- You can run the script from the server console by placing it as a lua file in the garrysmod/lua directory on the server, then running this command: lua_openscript yourluafile.lua

 

4. Analyze the data:

- Download the console profiling tool here.

- Run the tool in the console, telling it where your server's profiles folder is. Example (PowerShell): ./gtool.exe "D:\Server\profiles"

- Tell gtool what you want it to do with your data. It will also ask you what units you want to use (seconds, milliseconds, etc).

- Look at the data. If you chose the .csv, open it with either google sheets, or microsoft excell.

 

Planned Features:

- A GUI tool to read the profile data and allow the user to easily interact with it. Here's a preview of the tool.

post-30942-0-74009100-1535219807_thumb.png

 

- Memory profiling to allow you to view how memory is utilized over time.

- Any other cool stuff I come up with.

Edited by Techmo
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Just added a quick feature, the gtool will now export .csv files containing the timing data for use in microsoft excell to make graphs and do other cool analysis things (<yourprofilename>.gpf.csv), as well as a .csv containing basic statistical data on all profiles examined by gtool in the server's "profiles" directory (profiles.csv).

Edited by Techmo
Link to comment
Share on other sites

  • 4 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share