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 | 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 | toggleStatus () |
Switches the profiler either on or off. | |
void | synchronizeFrame () |
Saves all data for the current frame, and starts the next frame in the circular buffer. | |
void | draw () |
Draw the markers. | |
void | onClick (const core::vector2di &mouse_pos) |
Handle freeze/unfreeze. | |
void | writeToFile () |
Saves the collected profile data to a file. | |
bool | isFrozen () const |
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. | |
void | drawBackground () |
Helper to draw a white background. | |
Private Attributes | |
std::vector< ThreadData > | m_all_threads_data |
Data structure containing all currently buffered markers. | |
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. | |
bool | m_has_wrapped_around |
True if the circular buffer has wrapped around. | |
int | m_max_frames |
The maximum number of frames to be buffered. | |
double | m_time_last_sync |
Time of last sync. | |
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. | |
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.