|
SuperTuxKart
|
class that allows run-time graphical profiling through the use of markers. More...
#include <profiler.hpp>
Classes | |
| class | EventData |
| The data for one event. More... | |
| class | Marker |
| struct | ThreadData |
Public Member Functions | |
| void | init () |
| It is split from the constructor so that it can be avoided allocating unnecessary memory when the profiler is never used (for example in no graphics). | |
| void | reset () |
| Reset profiling data held in memory, to allow starting a new clean profiling run. | |
| void | pushCPUMarker (const char *name="N/A", const video::SColor &color=video::SColor()) |
| Push a new marker that starts now. | |
| void | popCPUMarker () |
| Stop the last pushed marker. | |
| void | activate () |
| Switches the profiler on. | |
| void | desactivate () |
| Switches the profiler off and computes frametime analysis. | |
| void | synchronizeFrame () |
| Saves all data for the current frame, and starts the next frame in the circular buffer. More... | |
| void | draw () |
| Draw the markers. | |
| void | onClick (const core::vector2di &mouse_pos) |
| Handle freeze/unfreeze. | |
| void | computeStableFPS () |
| To be called once the data for a report has been collected, computes the average FPS, and for each integer FPS value from 1 to 1000, the proportion of frames fast enough for this FPS value, the proportion of time spent in frames fast enough for this FPS value, as well as the proportion of total benchmark time spent waiting for a frame beyond the normal duration of a frame at this FPS value. | |
| void | startBenchmark () |
| void | writeToFile () |
| Saves the collected profile data to a file. More... | |
| bool | isFrozen () const |
| void | setDrawing (bool drawing) |
| int | getTotalFrametime () |
| int | getTotalFrames () |
| int | getFPSMetricsHigh () |
| int | getFPSMetricsMid () |
| int | getFPSMetricsLow () |
Private Types | |
| enum | FreezeState { UNFROZEN , WAITING_FOR_FREEZE , FROZEN , WAITING_FOR_UNFREEZE } |
| typedef std::map< std::string, EventData > | AllEventData |
| The mapping of event names to the corresponding EventData. | |
Private Member Functions | |
| int | getThreadID () |
| Returns a unique index for a thread. More... | |
| void | drawBackground () |
| Helper to draw a white background. | |
Private Attributes | |
| std::vector< ThreadData > | m_all_threads_data |
| Data structure containing all currently buffered markers. More... | |
| std::vector< int > | m_gpu_times |
| Buffer for the GPU times (in ms). | |
| std::atomic< int > | m_threads_used |
| Counts the threads used. | |
| int | m_current_frame |
| Index of the current frame in the buffer. | |
| Synchronised< bool > | m_lock |
| We don't need the bool, but easiest way to get a lock for the whole instance (since we need to avoid that a synch is done which changes the current frame while another threaded uses this variable, or while a new thread is added. | |
| std::vector< int > | m_frame_times |
| Stores the frame times (in µs), once FPS metrics are computed. | |
| int | m_total_frametime |
| Stores the total duration of the frames analyzed (in µs), once FPS metrics are computed. More... | |
| int | m_total_frames |
| Stores the frame count. | |
| int | m_slow_frames [MAX_ANALYZED_FPS] |
| Store the count of slow frames for a given FPS value. | |
| int | m_time_spent_in_slow_frames [MAX_ANALYZED_FPS] |
| Store time spent in slow frames for a given FPS value (in µs) | |
| int | m_time_waited_in_slow_frames [MAX_ANALYZED_FPS] |
| Store time spent beyond the maximum duration of a frame for a given FPS value (in µs) | |
| int | m_fps_metrics_high |
| Store the highest FPS with <50% time in slow frames and < 10% time waited beyond maximum duration. | |
| int | m_fps_metrics_mid |
| Store the highest FPS with <12% time in slow frames and < 2% time waited beyond maximum duration. | |
| int | m_fps_metrics_low |
| Store the highest FPS with < 1% time in slow frames and <0.1% time waited beyond maximum duration. | |
| bool | m_has_wrapped_around |
| True if the circular buffer has wrapped around. | |
| bool | m_drawing |
| True if the profiler UI should be rendered. | |
| int | m_max_frames |
| The maximum number of frames to be buffered. More... | |
| double | m_time_last_sync |
| Time of last sync. More... | |
| double | m_time_between_sync |
| Time between now and last sync, used to scale the GUI bar. | |
| std::vector< std::string > | m_all_event_names |
| List of all event names. More... | |
| FreezeState | m_freeze_state |
class that allows run-time graphical profiling through the use of markers.
|
private |
Returns a unique index for a thread.
If the calling thread is not yet in the mapping, it will assign a new unique id to this thread.
| void Profiler::synchronizeFrame | ( | ) |
Saves all data for the current frame, and starts the next frame in the circular buffer.
Any events that are currently active (e.g. in a separate thread) will be split in two parts: the beginning (till now) in the current frame, the rest will be added to the next frame.
| void Profiler::writeToFile | ( | ) |
Saves the collected profile data to a file.
Filename is based on the stdout name (with -profile appended).
|
private |
List of all event names.
This list is sorted to make sure if the circular buffer is dumped more than once the order of events remains the same.
|
private |
Data structure containing all currently buffered markers.
The index is the thread id.
|
private |
The maximum number of frames to be buffered.
Used to minimise reallocations.
|
private |
Time of last sync.
All start/end times are stored relative to this time.
|
private |
Stores the total duration of the frames analyzed (in µs), once FPS metrics are computed.
Int overflow is not a concern unless more than 30 minutes of data is stored and analyzed.