An AddOn for displaying the time spent inside functions, to help find bottle necks in code. For developers only.
This AddOn is used exclusively through slash commands.
Enabling/Disabling CPU Profiling
- <tt>/fp e</tt>
Enable CPU Profiling.
This uses extra CPU cycles, even when the AddOn isn't running, so be sure to turn it off when you're done. This will cause the user interface to be reloaded.
- <tt>/fp d</tt>
Disable CPU Profiling.
This will cause the user interface to be reloaded.
By default, FunctionProfiler watches <tt>_G</tt>.
- <tt>/fp a [function | table]</tt>
Add a watch for a function or table.
Tables and their metatables are recursively checked for functions, and all found functions are added.
- <tt>/fp l</tt>
Lists all watched functions or tables.
- <tt>/fp r [function | table]</tt>
Removes a watched function or table.
- <tt>/fp rs</tt>
Rescans watched tables, useful if what you wanted to watch didn't exist when the AddOn was loaded.
- <tt>/fp f pattern</tt>
Filters watched functions using a Lua pattern.
The above slash commands can of course only watch things that are globally visible. This AddOn creates two global functions which you can call from inside your AddOn to watch local variables.
- <tt>AddFunctionWatch([function | table], name)</tt>
Watches a function or table. <tt>name</tt> is used for display purposes.
- <tt>RemoveFunctionWatch([function | table])</tt>
Removes a watch previously added by <tt>AddFunctionWatch()</tt>.
The Graph Window
- <tt>/fp s</tt>
Shows the graph window.
- <tt>/fp h</tt>
Hides the graph window.
The graph window can be dragged around using the left mouse button. The mouse wheel will increase or decrease the number of objects displayed. Right clicking changes how the items are sorted.
- Exclusive Time
Sort by the total time spent inside a function, not counting time spent in functions that it called.
- Inclusive Time
Sort by the total time spent inside a function, including time spent inside functions that it in turn called.
- Inclusive Time Per Call
Sort by the average total time spent inside a single call to a function, including the time spent in functions that it in turn called.
- Exclusive Time Per Call
Sort by the average time spent inside a single call to a function, not counting time spent in functions that it called.
When displaying inclusive calls, the bright part is the time spent inside the function in question, the dark part is time spent in functions that it called.
When a function can be seen from multiple locations, the one that would result in the shortest name is displayed.
The time between when a co-routine yields and when it is resumed counts towards the execution time of the function that yielded.
The code that searches for functions tries to find the shortest function name; if your filter is applied to a table that was found under multiple names, and a shorter name was discovered that didn't match the pattern first, any longer names, even if they do match, will be filtered anyway. I expect filtering works properly in most cases, and that the effort of checking every possible permutation isn't worth it.