78 #ifndef INCLUDED_PROFILER2 79 #define INCLUDED_PROFILER2 148 memcpy(buffer, &RESYNC_MAGIC,
sizeof(RESYNC_MAGIC));
149 memcpy(buffer +
sizeof(RESYNC_MAGIC), &t,
sizeof(t));
158 SItem_dt_id item = { (float)(t - m_LastTime),
id };
159 Write(type, &item,
sizeof(item));
170 float time = (float)(t - m_LastTime);
186 void PutOnHold(
u8 type);
187 void HoldToBuffer(
bool condensed);
188 void ThrowawayHoldBuffer();
205 std::string GetBuffer();
213 void WriteHold(
EItem type,
const void* item,
u32 itemSize);
229 memset(buffer,
ITEM_NOP, HOLD_BUFFER_SIZE);
437 static void TLSDtor(
void* data);
535 #define PROFILE2(region) CProfile2Region profile2__(region) 537 #define PROFILE2_IFSPIKE(region, limit) CProfile2SpikeRegion profile2__(region, limit) 539 #define PROFILE2_AGGREGATED(region, limit) CProfile2AggregatedRegion profile2__(region, limit) 541 #define PROFILE2_GPU(region) CProfile2GPURegion profile2gpu__(region) 546 #define PROFILE2_EVENT(name) g_Profiler2.RecordEvent(name) 554 #define PROFILE2_ATTR g_Profiler2.RecordAttribute 556 #endif // INCLUDED_PROFILER2 const char * m_Name
Definition: Profiler2.h:489
#define NONCOPYABLE(className)
Indicates that a class is noncopyable (usually due to const or reference members, or because the clas...
Definition: code_annotation.h:217
bool m_Initialised
Definition: Profiler2.h:446
Definition: Profiler2.h:104
static const size_t HOLD_BUFFER_SIZE
Definition: Profiler2.h:128
u8 type
Definition: Profiler2.h:246
const std::string & GetName()
Definition: Profiler2.h:195
friend class CProfile2AggregatedRegion
Definition: Profiler2.h:95
#define VPRINTF_ARGS(fmtpos)
Definition: code_annotation.h:244
CProfile2Region(const char *name)
Definition: Profiler2.h:468
int m_FrameNumber
Definition: Profiler2.h:448
Scope-based enter/leave helper.
Definition: Profiler2.h:483
void AddThreadStorage(ThreadStorage *storage)
Definition: Profiler2.cpp:297
void clear()
Definition: Profiler2.h:236
void RecordFrameStart()
Call in main thread at the start of a frame.
Definition: Profiler2.h:332
u8 * buffer
Definition: Profiler2.h:244
void RecordAttribute(const char *fmt,...) PRINTF_ARGS(2)
Definition: Profiler2.h:358
u32 m_BufferPos0
Definition: Profiler2.h:263
void PutOnHold(u8 type)
Definition: Profiler2.cpp:423
Definition: Profiler2.h:222
u8 HoldType()
Definition: Profiler2.h:379
CMutex m_Mutex
Definition: Profiler2.h:456
CProfiler2 & m_Profiler
Definition: Profiler2.h:215
CProfile2GPURegion(const char *name)
Definition: Profiler2.h:516
#define ASSERT(expr)
same as ENSURE in debug mode, does nothing in release mode.
Definition: debug.h:315
Definition: Profiler2GPU.cpp:34
CProfiler2 g_Profiler2
Definition: Profiler2.cpp:36
#define PRINTF_ARGS(fmtpos)
Definition: code_annotation.h:243
A non-recursive mutual exclusion lock.
Definition: ThreadUtil.h:45
void EnableHTTP()
Call in main thread to enable the HTTP server.
Definition: Profiler2.cpp:163
Scope-based enter/leave helper.
Definition: Profiler2.h:465
uint8_t u8
Definition: types.h:37
Definition: Profiler2.h:102
void ShutDownHTTP()
Call in main thread to shut down the profiler's HTTP server.
Definition: Profiler2.cpp:197
void RecordAttributePrintf(const char *fmt,...) PRINTF_ARGS(2)
Definition: Profiler2.h:176
void RecordLeave(double t)
Definition: Profiler2.h:168
void HoldToBuffer(bool condensed)
Definition: Profiler2.cpp:672
bool m_PushedHold
Definition: Profiler2.h:492
#define ARRAY_SIZE(name)
Definition: code_annotation.h:336
const char * id
Definition: Profiler2.h:121
u32 pos
Definition: Profiler2.h:245
HoldBuffer()
Definition: Profiler2.h:226
size_t HoldLevel()
Hold onto messages until a call to release or write the held messages.
Definition: Profiler2.h:374
void RecordGPURegionEnter(const char *id)
Definition: Profiler2.cpp:257
void RecordRegionEnter(const char *id, double time)
Definition: Profiler2.h:348
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
Definition: debug.h:287
double m_Limit
Definition: Profiler2.h:505
uint32_t u32
Definition: types.h:39
Definition: Profiler2.h:103
void IncrementFrameNumber()
Definition: Profiler2.h:426
void RecordSyncMarker(double t)
Definition: Profiler2.h:142
EItem
Item type identifiers.
Definition: Profiler2.h:100
const char * m_Name
Definition: Profiler2.h:504
void setType(u8 newType)
Definition: Profiler2.h:240
static const u8 RESYNC_MAGIC[8]
An arbitrary number to help resyncing with the item stream when parsing.
Definition: Profiler2.h:113
void RegisterCurrentThread(const std::string &name)
Call in any thread to enable the profiler in that thread.
Definition: Profiler2.cpp:281
double GetTime()
Definition: Profiler2.h:416
const char * m_Name
Definition: Profiler2.h:525
void SaveToFile()
Call in any thread to save a JSONP representation of the buffers for all threads, to a file named pro...
Definition: Profiler2.cpp:933
void RecordAttribute(const char *fmt, va_list argp) VPRINTF_ARGS(2)
Definition: Profiler2.cpp:394
ThreadStorage & GetThreadStorage()
Definition: Profiler2.h:439
size_t HoldLevel()
Definition: Profiler2.cpp:413
void ShutdownGPU()
Call in main thread to shut down the GPU profiling support, before shutting down OpenGL.
Definition: Profiler2.cpp:191
static const size_t BUFFER_SIZE
Definition: Profiler2.h:127
const char * m_Name
Definition: Profiler2.h:477
void Record(EItem type, double t, const char *id)
Definition: Profiler2.h:154
Definition: Profiler2.h:91
void RecordGPURegionLeave(const char *id)
Definition: Profiler2.cpp:263
void ThrowawayHoldBuffer()
Definition: Profiler2.cpp:715
void Initialise()
Call in main thread to set up the profiler, before calling any other profiler functions.
Definition: Profiler2.cpp:147
~CProfile2Region()
Definition: Profiler2.h:472
CProfiler2 & GetProfiler()
Definition: Profiler2.h:190
double timer_Time()
Definition: timer.cpp:98
u8 * m_Buffer
Definition: Profiler2.h:220
void * pthread_getspecific(pthread_key_t key)
Definition: wpthread.cpp:184
Definition: Profiler2.h:105
void RecordRegionLeave()
Definition: Profiler2.h:353
u8 HoldType()
Definition: Profiler2.cpp:418
Definition: Profiler2.h:140
std::string m_Name
Definition: Profiler2.h:216
double m_Limit
Definition: Profiler2.h:490
void RecordRegionEnter(const char *id)
Definition: Profiler2.h:343
Scope-based enter/leave helper.
Definition: Profiler2.h:498
void Shutdown()
Call in main thread to shut everything down.
Definition: Profiler2.cpp:222
mg_context * m_MgContext
Definition: Profiler2.h:450
double m_LastTime
Definition: Profiler2.h:218
Used by CProfiler2 for GPU profiling support.
Definition: Profiler2GPU.h:31
Definition: Profiler2.h:107
void RecordGPUFrameStart()
Definition: Profiler2.cpp:245
CProfiler2GPU * m_GPU
Definition: Profiler2.h:454
void EnableGPU()
Call in main thread to enable the GPU profiling support, after OpenGL has been initialised.
Definition: Profiler2.cpp:181
~CProfiler2()
Definition: Profiler2.cpp:46
double m_StartTime
Definition: Profiler2.h:506
~CProfile2GPURegion()
Definition: Profiler2.h:520
void StopHoldingMessages(bool writeToBuffer, bool condensed=false)
Definition: Profiler2.h:389
void Toggle()
Call in main thread to enable/disable the profiler.
Definition: Profiler2.cpp:207
pthread_key_t m_TLS
Definition: Profiler2.h:452
void RecordEvent(const char *id)
Definition: Profiler2.h:338
bool IsMainThread()
Returns whether the current thread is the 'main' thread (i.e.
Definition: ThreadUtil.cpp:25
void RemoveThreadStorage(ThreadStorage *storage)
Definition: Profiler2.cpp:303
float dt
Definition: Profiler2.h:120
Definition: Profiler2.h:106
size_t m_HeldDepth
Definition: Profiler2.h:250
CProfiler2()
Definition: Profiler2.cpp:41
double m_StartTime
Definition: Profiler2.h:491
static const size_t MAX_ATTRIBUTE_LENGTH
Definition: Profiler2.h:110
friend class CProfile2SpikeRegion
Definition: Profiler2.h:94
void InitialiseGPU()
Definition: Profiler2.cpp:157
void RecordGPUFrameEnd()
Definition: Profiler2.cpp:251
Scope-based GPU enter/leave helper.
Definition: Profiler2.h:513
void ConstructJSONOverview(std::ostream &stream)
Call in any thread to produce a JSON representation of the general state of the application.
Definition: Profiler2.cpp:722
bool m_PushedHold
Definition: Profiler2.h:507
void Write(u64 reg, u64 value)
Definition: msr.cpp:136
unsigned int pthread_key_t
Definition: wpthread.h:93
u32 m_BufferPos1
Definition: Profiler2.h:264
void RecordSyncMarker()
Non-main threads should call this occasionally, especially if it's been a long time since their last ...
Definition: Profiler2.h:324
Definition: mongoose.cpp:481
An item with a relative time and an ID string pointer.
Definition: Profiler2.h:118
~HoldBuffer()
Definition: Profiler2.h:232
void HoldMessages(u8 type)
Definition: Profiler2.h:384
std::vector< ThreadStorage * > m_Threads
Definition: Profiler2.h:457
int GetFrameNumber()
Definition: Profiler2.h:421
static void TLSDtor(void *data)
Called by pthreads when a registered thread is destroyed.
Definition: Profiler2.cpp:272
Class instantiated in every registered thread.
Definition: Profiler2.h:133
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.
Definition: Profiler2.cpp:895
void RecordFrameStart(double t)
Definition: Profiler2.h:162