-
Notifications
You must be signed in to change notification settings - Fork 3
Perf
Perf manages frame based performance tracking tools like the [PerfTrack] attribute.
Performance tracking of scopes and functions is only available if DEBUG is defined and is also disabled by default. Set Perf.Track to true to enable the collection of that data.
The performance data is collected over the span of Perf.TrackCollectionInterval (counted in frames/loops, defaults to 30). After that, the accumulated time per tracked function or scope is averaged out to represent a single frame.
The core loop is tracked directly. This will provide entries for Pile.Core.Run:Render, Pile.Core.Run:Update and Pile.Core.Run:Loop (no sleep).
The [PerfTrack] attribute can simply be put on functions to track their execution times. The name of the scope is the full name of the function (including namespace and class/struct) by default, but can be overridden like so [PerfTrack("A Scope")]. You can also append to the original name.
Tracking scopes can be done by adding PerfTrack("<scope name>"); into your code, preferably at the beginning of a new scope. This will show up just like the attribute but here you have to put in the name yourself in any case.
Perf.Render(...) renders performance data to a given batch using the given font. (0, 0) will be the top left origin of the drawn data, meaning that if you draw that batch on screen without transforming it, it will appear in the top left corner. Even if Perf.Track is false, this still displays the current fps, theoretical fps (at the current delta without sleep) as well as the Time.Delta and Time.Duration values. With Perf.Track enabled, it renders a list of the most time consuming functions tracked below that.