Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
#include <Profiler2.h>
Classes | |
struct | SItem_dt_id |
An item with a relative time and an ID string pointer. More... | |
class | ThreadStorage |
Class instantiated in every registered thread. More... | |
Public Types | |
enum | EItem { ITEM_NOP = 0 , ITEM_SYNC = 1 , ITEM_EVENT = 2 , ITEM_ENTER = 3 , ITEM_LEAVE = 4 , ITEM_ATTRIBUTE = 5 } |
Item type identifiers. More... | |
Public Member Functions | |
CProfiler2 () | |
~CProfiler2 () | |
void | Initialise () |
Call in main thread to set up the profiler, before calling any other profiler functions. More... | |
void | EnableHTTP () |
Call in main thread to enable the HTTP server. More... | |
void | EnableGPU () |
Call in main thread to enable the GPU profiling support, after OpenGL has been initialised. More... | |
void | ShutdownGPU () |
Call in main thread to shut down the GPU profiling support, before shutting down OpenGL. More... | |
void | ShutDownHTTP () |
Call in main thread to shut down the profiler's HTTP server. More... | |
void | Toggle () |
Call in main thread to enable/disable the profiler. More... | |
void | Shutdown () |
Call in main thread to shut everything down. More... | |
void | RegisterCurrentThread (const std::string &name) |
Call in any thread to enable the profiler in that thread. More... | |
void | RecordSyncMarker () |
Non-main threads should call this occasionally, especially if it's been a long time since their last call to the profiler, or if they've made thousands of calls since the last sync marker. More... | |
void | RecordFrameStart () |
Call in main thread at the start of a frame. More... | |
void | RecordEvent (const char *id) |
void | RecordRegionEnter (const char *id) |
void | RecordRegionEnter (const char *id, double time) |
void | RecordRegionLeave () |
void | RecordAttribute (const char *fmt,...) PRINTF_ARGS(2) |
void | RecordGPUFrameStart () |
void | RecordGPUFrameEnd () |
void | RecordGPURegionEnter (const char *id) |
void | RecordGPURegionLeave (const char *id) |
size_t | HoldLevel () |
Hold onto messages until a call to release or write the held messages. More... | |
u8 | HoldType () |
void | HoldMessages (u8 type) |
void | StopHoldingMessages (bool writeToBuffer, bool condensed=false) |
void | ConstructJSONOverview (std::ostream &stream) |
Call in any thread to produce a JSON representation of the general state of the application. More... | |
const char * | ConstructJSONResponse (std::ostream &stream, const std::string &thread) |
Call in any thread to produce a JSON representation of the buffer for a given thread. More... | |
void | SaveToFile () |
Call in any thread to save a JSONP representation of the buffers for all threads, to a file named profile2.jsonp in the logs directory. More... | |
double | GetTime () |
int | GetFrameNumber () |
void | IncrementFrameNumber () |
void | AddThreadStorage (ThreadStorage *storage) |
void | RemoveThreadStorage (ThreadStorage *storage) |
Static Public Attributes | |
static const size_t | MAX_ATTRIBUTE_LENGTH = 256 |
static const u8 | RESYNC_MAGIC [8] = {0x11, 0x22, 0x33, 0x44, 0xf4, 0x93, 0xbe, 0x15} |
An arbitrary number to help resyncing with the item stream when parsing. More... | |
Private Member Functions | |
void | InitialiseGPU () |
ThreadStorage & | GetThreadStorage () |
Private Attributes | |
bool | m_Initialised |
int | m_FrameNumber |
mg_context * | m_MgContext |
CProfiler2GPU * | m_GPU |
std::mutex | m_Mutex |
std::vector< std::unique_ptr< ThreadStorage > > | m_Threads |
Static Private Attributes | |
static const size_t | BUFFER_SIZE = 4 * 1024 * 1024 |
static const size_t | HOLD_BUFFER_SIZE = 128 * 1024 |
static thread_local ThreadStorage * | m_CurrentStorage = nullptr |
Friends | |
class | CProfiler2GPUARB |
class | CProfile2SpikeRegion |
class | CProfile2AggregatedRegion |
enum CProfiler2::EItem |
CProfiler2::CProfiler2 | ( | ) |
CProfiler2::~CProfiler2 | ( | ) |
void CProfiler2::AddThreadStorage | ( | ThreadStorage * | storage | ) |
void CProfiler2::ConstructJSONOverview | ( | std::ostream & | stream | ) |
Call in any thread to produce a JSON representation of the general state of the application.
const char * CProfiler2::ConstructJSONResponse | ( | std::ostream & | stream, |
const std::string & | thread | ||
) |
Call in any thread to produce a JSON representation of the buffer for a given thread.
Returns NULL on success, or an error string.
void CProfiler2::EnableGPU | ( | ) |
Call in main thread to enable the GPU profiling support, after OpenGL has been initialised.
void CProfiler2::EnableHTTP | ( | ) |
Call in main thread to enable the HTTP server.
(Disabled by default for security and performance and to avoid annoying a firewall.)
|
inline |
|
inlineprivate |
|
inline |
|
inline |
Hold onto messages until a call to release or write the held messages.
|
inline |
|
inline |
|
inline |
void CProfiler2::Initialise | ( | ) |
Call in main thread to set up the profiler, before calling any other profiler functions.
|
private |
|
inline |
|
inline |
|
inline |
Call in main thread at the start of a frame.
void CProfiler2::RecordGPUFrameEnd | ( | ) |
void CProfiler2::RecordGPUFrameStart | ( | ) |
void CProfiler2::RecordGPURegionEnter | ( | const char * | id | ) |
void CProfiler2::RecordGPURegionLeave | ( | const char * | id | ) |
|
inline |
|
inline |
|
inline |
|
inline |
Non-main threads should call this occasionally, especially if it's been a long time since their last call to the profiler, or if they've made thousands of calls since the last sync marker.
void CProfiler2::RegisterCurrentThread | ( | const std::string & | name | ) |
Call in any thread to enable the profiler in that thread.
name
should be unique, and is used by the visualiser to identify this thread.
void CProfiler2::RemoveThreadStorage | ( | ThreadStorage * | storage | ) |
void CProfiler2::SaveToFile | ( | ) |
Call in any thread to save a JSONP representation of the buffers for all threads, to a file named profile2.jsonp in the logs directory.
void CProfiler2::Shutdown | ( | ) |
Call in main thread to shut everything down.
All other profiled threads should have been terminated already.
void CProfiler2::ShutdownGPU | ( | ) |
Call in main thread to shut down the GPU profiling support, before shutting down OpenGL.
void CProfiler2::ShutDownHTTP | ( | ) |
Call in main thread to shut down the profiler's HTTP server.
|
inline |
void CProfiler2::Toggle | ( | ) |
Call in main thread to enable/disable the profiler.
|
friend |
|
friend |
|
friend |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
static |
|
static |
An arbitrary number to help resyncing with the item stream when parsing.