Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
CProfiler2 Class Reference

#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 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 RecordRegionLeave (const char *id)
 
void RecordAttribute (const char *fmt,...) PRINTF_ARGS(2)
 
void RecordGPUFrameStart ()
 
void RecordGPUFrameEnd ()
 
void RecordGPURegionEnter (const char *id)
 
void RecordGPURegionLeave (const char *id)
 
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 ()
 
ThreadStorageGetThreadStorage ()
 

Static Private Member Functions

static void TLSDtor (void *data)
 Called by pthreads when a registered thread is destroyed. More...
 

Private Attributes

bool m_Initialised
 
int m_FrameNumber
 
mg_contextm_MgContext
 
pthread_key_t m_TLS
 
CProfiler2GPUm_GPU
 
CMutex m_Mutex
 
std::vector< ThreadStorage * > m_Threads
 

Static Private Attributes

static const size_t BUFFER_SIZE = 1024*1024
 

Friends

class CProfiler2GPU_base
 

Detailed Description

Definition at line 91 of file Profiler2.h.

Member Enumeration Documentation

Item type identifiers.

Enumerator
ITEM_NOP 
ITEM_SYNC 
ITEM_EVENT 
ITEM_ENTER 
ITEM_LEAVE 
ITEM_ATTRIBUTE 

Definition at line 99 of file Profiler2.h.

Constructor & Destructor Documentation

CProfiler2::CProfiler2 ( )

Definition at line 40 of file Profiler2.cpp.

CProfiler2::~CProfiler2 ( )

Definition at line 45 of file Profiler2.cpp.

Member Function Documentation

void CProfiler2::AddThreadStorage ( ThreadStorage storage)

Definition at line 257 of file Profiler2.cpp.

void CProfiler2::ConstructJSONOverview ( std::ostream &  stream)

Call in any thread to produce a JSON representation of the general state of the application.

Definition at line 325 of file Profiler2.cpp.

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.

Definition at line 502 of file Profiler2.cpp.

void CProfiler2::EnableGPU ( )

Call in main thread to enable the GPU profiling support, after OpenGL has been initialised.

Definition at line 174 of file Profiler2.cpp.

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.)

Definition at line 157 of file Profiler2.cpp.

int CProfiler2::GetFrameNumber ( )
inline

Definition at line 362 of file Profiler2.h.

ThreadStorage& CProfiler2::GetThreadStorage ( )
inlineprivate

Definition at line 380 of file Profiler2.h.

double CProfiler2::GetTime ( )
inline

Definition at line 357 of file Profiler2.h.

void CProfiler2::IncrementFrameNumber ( )
inline

Definition at line 367 of file Profiler2.h.

void CProfiler2::Initialise ( )

Call in main thread to set up the profiler, before calling any other profiler functions.

Definition at line 141 of file Profiler2.cpp.

void CProfiler2::InitialiseGPU ( )
private

Definition at line 151 of file Profiler2.cpp.

void CProfiler2::RecordAttribute ( const char *  fmt,
  ... 
)
inline

Definition at line 325 of file Profiler2.h.

void CProfiler2::RecordEvent ( const char *  id)
inline

Definition at line 310 of file Profiler2.h.

void CProfiler2::RecordFrameStart ( )
inline

Call in main thread at the start of a frame.

Definition at line 304 of file Profiler2.h.

void CProfiler2::RecordGPUFrameEnd ( )

Definition at line 211 of file Profiler2.cpp.

void CProfiler2::RecordGPUFrameStart ( )

Definition at line 205 of file Profiler2.cpp.

void CProfiler2::RecordGPURegionEnter ( const char *  id)

Definition at line 217 of file Profiler2.cpp.

void CProfiler2::RecordGPURegionLeave ( const char *  id)

Definition at line 223 of file Profiler2.cpp.

void CProfiler2::RecordRegionEnter ( const char *  id)
inline

Definition at line 315 of file Profiler2.h.

void CProfiler2::RecordRegionLeave ( const char *  id)
inline

Definition at line 320 of file Profiler2.h.

void CProfiler2::RecordSyncMarker ( )
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.

Definition at line 296 of file Profiler2.h.

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.

Definition at line 241 of file Profiler2.cpp.

void CProfiler2::RemoveThreadStorage ( ThreadStorage storage)

Definition at line 263 of file Profiler2.cpp.

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.

Definition at line 540 of file Profiler2.cpp.

void CProfiler2::Shutdown ( void  )

Call in main thread to shut everything down.

All other profiled threads should have been terminated already.

Definition at line 186 of file Profiler2.cpp.

void CProfiler2::ShutdownGPU ( )

Call in main thread to shut down the GPU profiling support, before shutting down OpenGL.

Definition at line 181 of file Profiler2.cpp.

void CProfiler2::TLSDtor ( void *  data)
staticprivate

Called by pthreads when a registered thread is destroyed.

Definition at line 232 of file Profiler2.cpp.

Friends And Related Function Documentation

friend class CProfiler2GPU_base
friend

Definition at line 93 of file Profiler2.h.

Member Data Documentation

const size_t CProfiler2::BUFFER_SIZE = 1024*1024
staticprivate

Definition at line 126 of file Profiler2.h.

int CProfiler2::m_FrameNumber
private

Definition at line 389 of file Profiler2.h.

CProfiler2GPU* CProfiler2::m_GPU
private

Definition at line 395 of file Profiler2.h.

bool CProfiler2::m_Initialised
private

Definition at line 387 of file Profiler2.h.

mg_context* CProfiler2::m_MgContext
private

Definition at line 391 of file Profiler2.h.

CMutex CProfiler2::m_Mutex
private

Definition at line 397 of file Profiler2.h.

std::vector<ThreadStorage*> CProfiler2::m_Threads
private

Definition at line 398 of file Profiler2.h.

pthread_key_t CProfiler2::m_TLS
private

Definition at line 393 of file Profiler2.h.

const size_t CProfiler2::MAX_ATTRIBUTE_LENGTH = 256
static

Definition at line 109 of file Profiler2.h.

const u8 CProfiler2::RESYNC_MAGIC = {0x11, 0x22, 0x33, 0x44, 0xf4, 0x93, 0xbe, 0x15}
static

An arbitrary number to help resyncing with the item stream when parsing.

Definition at line 112 of file Profiler2.h.


The documentation for this class was generated from the following files: