• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    Lua
  • License
    GNU Lesser Genera...
  • Created over 8 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Profiler for Garry's Mod.

Garry's mod profiler

A profiler based on debug.sethook and SysTime. Perfect for the following things:

  • Finding performance bottlenecks (i.e. which code is spent the most time on)
  • Finding out which functions are called most
  • Identifying the source of lag spikes
  • Profiling specific functions

This profiler distinguishes itself from DBugR in its approach. DBugR profiles at hooks, timers and net messages specifically. FProfiler looks purely at functions outside of their context.

I would recommend DBugR to measure networking and/or specific hooks and/or timers. I would recommend FProfiler for the things mentioned above.

Using FProfiler

The FProfiler console command opens the profiler. Everything can be done from there.

Here's an explanation of the FProfiler menu:

UI thing Description
Realm Whether you're profiling the client or the server. Note: You need to be a SuperAdmin (or have the FProfiler permission in your favourite admin mod) to be allowed to do any serverside profiling!
(Re)start profiling Starts a profiling session. If there is any previous profiling session, it starts anew, disregarding any old data.
Stop profiling Stop an ongoing profiling session.
Continue profiling Continue a profiling session that has previously been stopped. It will simply continue gathering data.
Profiling Focus Focus the profiling on a specific function. Note: you cannot put arbitrary Lua in there, just function names! E.g. player.GetAll will work, but hook.GetTable().Think.Cavity will not.
Bottlenecks Shows the functions that the game has spent its most time on. The top ones are the ones that hurt your FPS most.
Top n most expensive Perfect for finding the cause of lag spikes. Lists the functions that took a long time on specific times they were called. Differs from the Bottlenecks tab in that Bottlenecks is about all the times the functions were called, this tab is about the single times they ran at their slowest.
Focus button Sets the profiling focus to the selected function

Using FProfiler in code

FProfiler has an API, a simple one too. All functions listed below are shared:

-- Starts profiling.
-- When focus is given, the profiler will only profile the focussed upon function, and the functions it calls
FProfiler.start([focus])

-- Stops profiling
FProfiler.stop()

-- Continue profiling
FProfiler.continueProfiling()

All the data of the profiling sessions can be seen in the FProfiler menu. Because of that, there need to be no data retrieving functions in the API. If you don't want to use the UI, you probably want the profiling in a custom format. There are some internal functions available for that. Check out lua/fprofiler/gather.lua and lua/fprofiler/report.

About bottlenecks

When faced with performance problems, people tend to dive in the code to perform micro-optimisations. Think of localising libraries to the scope of a file, storing LocalPlayer() in a variable for re-use and that kind of stuff. This is a naive approach and is unlikely to get you very far. The reason for that is very simple: micro-optimisations have very little effect on the eventual performance of the game. They're called micro-optimisations for a reason.

What you should be after is macro-optimisations, i.e. the big guys. Attacking those will give you the biggest benefit. Doubling your FPS is not uncommon when you attack the big guys.

What do I mean by macro-optimisation/the big guys you ask? Think of reducing an O(n^2) algorithm to an O(n lg n) one. Think of things like using more efficient data structures, more efficient algorithms, caching the results of complicated calculations, alternative ways to calculate things that don't give the exact right result, but give a "good enough" result and are way faster than the original algorithm. THAT kind of shit.

That's where the profiler comes in. Always mistrust what you think is a big performance hog is, measure it. Even the assumptions of people who have optimising code as their profession are often proven wrong by the profiler. Don't be smug and think you can do any better.

When working on performance, the profiler is to be your guide. The profiler is to tell you what to optimise. Do not bother with anything other than the most expensive functions for you will be wasting your time.

More Repositories

1

DarkRP

DarkRP, a non-serious roleplay gamemode for Garry's Mod.
Lua
463
star
2

GLuaFixer

Linter for Garry's mod Lua.
Haskell
141
star
3

darkrpmodification

This is the addon with which you can modify DarkRP. Do not edit DarkRP files, edit files in this addon instead.
Lua
122
star
4

miso-isomorphic-example

Minimalistic single page example of Miso's isomorphic feature.
Haskell
93
star
5

Sublime-GLua-Highlight

GMod Lua syntax highlighting for Sublime Text 2 and 3
Lua
48
star
6

Falcos-Prop-protection

Falco's prop protection
Lua
35
star
7

gmosh

Garry's mod workshop cli powertool. It should still work, but support has been dropped because of the effort required to compile the project
Python
33
star
8

miso-component-example

Simple component example
Haskell
30
star
9

MySQLite

Lua module for Garry's mod. Depends on MySQLOO or tmysql4.
Lua
22
star
10

gmcl_midi

Do you have a MIDI to USB cable? This module makes it possible to get MIDI events in Garry's mod! Not currently supported anymore.
C++
21
star
11

FSpectate

Spectate mod for Garry's Mod. Ripped from FAdmin.
Lua
12
star
12

AndroidGmod

Android interaction with Garry's mod!
Java
10
star
13

glualint-web

Online glualint linting. How cool is that?
Haskell
9
star
14

GModFunctional

Functional library for Garry's mod
Lua
7
star
15

miso-jswidget-example

Example of embedding arbitrary javascript widgets into Miso.
Haskell
7
star
16

UUAGC-Examples

Contains some guides and examples related to the Utrecht University Attribute Grammar Compiler (UUAGC)
6
star
17

SublimeLinter-contrib-glualint

Linter for Garry's Mod Lua plugin for Sublime Text 3
Python
5
star
18

vscode-semaphore-ci

Unofficial VS Code extension for interacting with Semaphore CI
TypeScript
5
star
19

GLuaParser

Out of date! Please use https://github.com/FPtje/GLuaFixer instead!
Haskell
4
star
20

linter-glualint

glualint linter plugin for Atom
CoffeeScript
4
star
21

DarkRPMotd

DarkRP MOTD page
3
star
22

simplerr

Simplifies syntax
Lua
2
star
23

falco-backup-drive

Program to automatically manage my backup drive
Haskell
2
star
24

DarkRPWikiGen

DarkRP's wiki generator, using pywikibot
Lua
2
star
25

DarkRPWikiGenerator

Wiki generator for DarkRP stubs
PHP
1
star
26

servant-client-ghcjs-test

Quick, dirty, manual copy paste hack to test servant-client-ghcjs
Haskell
1
star
27

FPtje

My profile
1
star
28

elm-marshall-example

Heavy WIP experimental project to have ghcjs and Elm live together in peace, or pieces.
Haskell
1
star
29

elm-marshall

Provide marshalling between Elm and ghcjs. Allows ghcjs to become Elm's IO monad.
Haskell
1
star