21#include "utils/synchronised.hpp" 
   51    Q_COMBINE_DIFFUSE_COLOR,
 
   69double getTimeMilliseconds();
 
   71#define ENABLE_PROFILER 
   74    #define PROFILER_PUSH_CPU_MARKER(name, r, g, b) \ 
   75        profiler.pushCPUMarker(name, video::SColor(0xFF, r, g, b)) 
   77    #define PROFILER_POP_CPU_MARKER()  \ 
   78        profiler.popCPUMarker() 
   80    #define PROFILER_SYNC_FRAME()   \ 
   81        profiler.synchronizeFrame() 
   83    #define PROFILER_DRAW() \ 
   86    #define PROFILER_PUSH_CPU_MARKER(name, r, g, b) 
   87    #define PROFILER_POP_CPU_MARKER() 
   88    #define PROFILER_SYNC_FRAME() 
   89    #define PROFILER_DRAW() 
  122        Marker(
double start, 
size_t layer=0)
 
  127        Marker(
const Marker& ref)
 
  142        size_t getLayer()
 const { 
return m_layer;  }
 
  177        EventData(video::SColor colour, 
int max_size)
 
  184        void setStart(
size_t frame, 
double start, 
int layer)
 
  269        WAITING_FOR_UNFREEZE,
 
  272    FreezeState     m_freeze_state;
 
  283                           const video::SColor& color=video::SColor());
 
  288    void     onClick(
const core::vector2di& mouse_pos);
 
  292    bool isFrozen()
 const { 
return m_freeze_state == FROZEN; }
 
The data for one event.
Definition: profiler.hpp:167
 
void setStart(size_t frame, double start, int layer)
Records the start of an event for a given frame.
Definition: profiler.hpp:184
 
std::vector< Marker > m_all_markers
Vector of all buffered markers.
Definition: profiler.hpp:173
 
video::SColor getColour() const
Returns the colour for this event.
Definition: profiler.hpp:201
 
video::SColor m_colour
Colour to use in the on-screen display.
Definition: profiler.hpp:170
 
void setEnd(size_t frame, double end)
Records the end of an event for a given frame.
Definition: profiler.hpp:191
 
Definition: profiler.hpp:104
 
void setStart(double start, size_t layer=0)
Sets start time and layer for this event.
Definition: profiler.hpp:149
 
double m_start
An event that is started (pushed) stores the start time in this variable.
Definition: profiler.hpp:108
 
double m_duration
Duration of the event in this frame (accumulated if this event should be recorded more than once).
Definition: profiler.hpp:113
 
double getEnd() const
Returns the end time of this event marker.
Definition: profiler.hpp:137
 
double getDuration() const
Returns the duration of this event.
Definition: profiler.hpp:140
 
double getStart() const
Returns the start time of this event marker.
Definition: profiler.hpp:134
 
void setEnd(double end)
Sets the end time of this event.
Definition: profiler.hpp:155
 
size_t m_layer
Distance of marker from root (for nested events), used to adjust vertical height when drawing.
Definition: profiler.hpp:116
 
void clear()
Called when an entry in the cyclic buffer is reused.
Definition: profiler.hpp:146
 
class that allows run-time graphical profiling through the use of markers.
Definition: profiler.hpp:100
 
std::vector< int > m_gpu_times
Buffer for the GPU times (in ms).
Definition: profiler.hpp:230
 
void onClick(const core::vector2di &mouse_pos)
Handle freeze/unfreeze.
Definition: profiler.cpp:478
 
double m_time_between_sync
Time between now and last sync, used to scale the GUI bar.
Definition: profiler.hpp:256
 
void toggleStatus()
Switches the profiler either on or off.
Definition: profiler.cpp:206
 
std::vector< ThreadData > m_all_threads_data
Data structure containing all currently buffered markers.
Definition: profiler.hpp:227
 
std::vector< std::string > m_all_event_names
List of all event names.
Definition: profiler.hpp:261
 
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 ...
Definition: profiler.hpp:242
 
void synchronizeFrame()
Saves all data for the current frame, and starts the next frame in the circular buffer.
Definition: profiler.cpp:224
 
int getThreadID()
Returns a unique index for a thread.
Definition: profiler.cpp:121
 
void drawBackground()
Helper to draw a white background.
Definition: profiler.cpp:513
 
std::map< std::string, EventData > AllEventData
The mapping of event names to the corresponding EventData.
Definition: profiler.hpp:207
 
int m_max_frames
The maximum number of frames to be buffered.
Definition: profiler.hpp:249
 
void draw()
Draw the markers.
Definition: profiler.cpp:290
 
double m_time_last_sync
Time of last sync.
Definition: profiler.hpp:253
 
void writeToFile()
Saves the collected profile data to a file.
Definition: profiler.cpp:534
 
void popCPUMarker()
Stop the last pushed marker.
Definition: profiler.cpp:173
 
void init()
It is split from the constructor so that it can be avoided allocating unnecessary memory when the pro...
Definition: profiler.cpp:109
 
std::atomic< int > m_threads_used
Counts the threads used.
Definition: profiler.hpp:233
 
int m_current_frame
Index of the current frame in the buffer.
Definition: profiler.hpp:236
 
bool m_has_wrapped_around
True if the circular buffer has wrapped around.
Definition: profiler.hpp:245
 
void pushCPUMarker(const char *name="N/A", const video::SColor &color=video::SColor())
Push a new marker that starts now.
Definition: profiler.cpp:137
 
A variable that is automatically synchronised using pthreads mutex.
Definition: synchronised.hpp:28
 
Definition: profiler.hpp:210
 
std::vector< std::string > m_ordered_headings
This stores the event names in the order in which they occur.
Definition: profiler.hpp:218
 
std::vector< std::string > m_event_stack
Stack of events to detect nesting.
Definition: profiler.hpp:212