78 #ifndef INCLUDED_PROFILER2 79 #define INCLUDED_PROFILER2 152 memcpy(buffer, &RESYNC_MAGIC,
sizeof(RESYNC_MAGIC));
153 memcpy(buffer +
sizeof(RESYNC_MAGIC), &t,
sizeof(t));
162 SItem_dt_id item = { (float)(t - m_LastTime),
id };
163 Write(type, &item,
sizeof(item));
174 float time = (float)(t - m_LastTime);
190 void PutOnHold(
u8 type);
191 void HoldToBuffer(
bool condensed);
192 void ThrowawayHoldBuffer();
209 std::string GetBuffer();
215 void Write(
EItem type,
const void* item,
u32 itemSize);
217 void WriteHold(
EItem type,
const void* item,
u32 itemSize);
233 memset(buffer,
ITEM_NOP, HOLD_BUFFER_SIZE);
536 #define PROFILE2(region) CProfile2Region profile2__(region) 538 #define PROFILE2_IFSPIKE(region, limit) CProfile2SpikeRegion profile2__(region, limit) 540 #define PROFILE2_AGGREGATED(region, limit) CProfile2AggregatedRegion profile2__(region, limit) 542 #define PROFILE2_GPU(region) CProfile2GPURegion profile2gpu__(region) 547 #define PROFILE2_EVENT(name) g_Profiler2.RecordEvent(name) 555 #define PROFILE2_ATTR g_Profiler2.RecordAttribute 557 #endif // INCLUDED_PROFILER2 const char * m_Name
Definition: Profiler2.h:490
#define NONCOPYABLE(className)
Indicates that a class is noncopyable (usually due to const or reference members, or because the clas...
Definition: code_annotation.h:227
bool m_Initialised
Definition: Profiler2.h:447
Definition: Profiler2.h:109
static const size_t HOLD_BUFFER_SIZE
Definition: Profiler2.h:132
u8 type
Definition: Profiler2.h:250
Definition: Profiler2.h:144
const std::string & GetName()
Definition: Profiler2.h:199
friend class CProfile2AggregatedRegion
Definition: Profiler2.h:100
#define VPRINTF_ARGS(fmtpos)
Definition: code_annotation.h:256
std::vector< std::unique_ptr< ThreadStorage > > m_Threads
Definition: Profiler2.h:458
CProfile2Region(const char *name)
Definition: Profiler2.h:469
int m_FrameNumber
Definition: Profiler2.h:449
Scope-based enter/leave helper.
Definition: Profiler2.h:484
void AddThreadStorage(ThreadStorage *storage)
Definition: Profiler2.cpp:303
void clear()
Definition: Profiler2.h:240
void RecordFrameStart()
Call in main thread at the start of a frame.
Definition: Profiler2.h:336
u8 * buffer
Definition: Profiler2.h:248
void RecordAttribute(const char *fmt,...) PRINTF_ARGS(2)
Definition: Profiler2.h:362
u32 m_BufferPos0
Definition: Profiler2.h:267
void PutOnHold(u8 type)
Definition: Profiler2.cpp:430
Definition: Profiler2.h:226
u8 HoldType()
Definition: Profiler2.h:383
CProfiler2 & m_Profiler
Definition: Profiler2.h:219
CProfile2GPURegion(const char *name)
Definition: Profiler2.h:517
CProfiler2 g_Profiler2
Definition: Profiler2.cpp:44
#define PRINTF_ARGS(fmtpos)
Definition: code_annotation.h:255
void EnableHTTP()
Call in main thread to enable the HTTP server.
Definition: Profiler2.cpp:177
Scope-based enter/leave helper.
Definition: Profiler2.h:466
uint8_t u8
Definition: types.h:37
Definition: Profiler2.h:107
void ShutDownHTTP()
Call in main thread to shut down the profiler's HTTP server.
Definition: Profiler2.cpp:222
void RecordAttributePrintf(const char *fmt,...) PRINTF_ARGS(2)
Definition: Profiler2.h:180
void RecordLeave(double t)
Definition: Profiler2.h:172
void HoldToBuffer(bool condensed)
Definition: Profiler2.cpp:681
bool m_PushedHold
Definition: Profiler2.h:493
#define ARRAY_SIZE(name)
Definition: code_annotation.h:348
const char * id
Definition: Profiler2.h:126
u32 pos
Definition: Profiler2.h:249
HoldBuffer()
Definition: Profiler2.h:230
size_t HoldLevel()
Hold onto messages until a call to release or write the held messages.
Definition: Profiler2.h:378
void RecordGPURegionEnter(const char *id)
Definition: Profiler2.cpp:277
std::mutex m_Mutex
Definition: Profiler2.h:455
void RecordRegionEnter(const char *id, double time)
Definition: Profiler2.h:352
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
Definition: debug.h:290
double m_Limit
Definition: Profiler2.h:506
uint32_t u32
Definition: types.h:39
Definition: Profiler2.h:108
void IncrementFrameNumber()
Definition: Profiler2.h:430
void RecordSyncMarker(double t)
Definition: Profiler2.h:146
bool IsMainThread()
Returns whether the current thread is the 'main' thread (i.e.
Definition: Threading.cpp:27
Definition: Profiler2GPU.cpp:48
EItem
Item type identifiers.
Definition: Profiler2.h:105
const char * m_Name
Definition: Profiler2.h:505
void setType(u8 newType)
Definition: Profiler2.h:244
static const u8 RESYNC_MAGIC[8]
An arbitrary number to help resyncing with the item stream when parsing.
Definition: Profiler2.h:118
void RegisterCurrentThread(const std::string &name)
Call in any thread to enable the profiler in that thread.
Definition: Profiler2.cpp:289
static thread_local ThreadStorage * m_CurrentStorage
Definition: Profiler2.h:457
double GetTime()
Definition: Profiler2.h:420
const char * m_Name
Definition: Profiler2.h:526
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:939
void RecordAttribute(const char *fmt, va_list argp) VPRINTF_ARGS(2)
Definition: Profiler2.cpp:400
ThreadStorage & GetThreadStorage()
Definition: Profiler2.h:441
size_t HoldLevel()
Definition: Profiler2.cpp:419
void ShutdownGPU()
Call in main thread to shut down the GPU profiling support, before shutting down OpenGL.
Definition: Profiler2.cpp:216
static const size_t BUFFER_SIZE
Definition: Profiler2.h:131
const char * m_Name
Definition: Profiler2.h:478
void Record(EItem type, double t, const char *id)
Definition: Profiler2.h:158
Definition: Profiler2.h:96
void RecordGPURegionLeave(const char *id)
Definition: Profiler2.cpp:283
void ThrowawayHoldBuffer()
Definition: Profiler2.cpp:724
void Initialise()
Call in main thread to set up the profiler, before calling any other profiler functions.
Definition: Profiler2.cpp:163
~CProfile2Region()
Definition: Profiler2.h:473
CProfiler2 & GetProfiler()
Definition: Profiler2.h:194
double timer_Time()
Definition: timer.cpp:130
u8 * m_Buffer
Definition: Profiler2.h:224
Definition: Profiler2.h:110
void RecordRegionLeave()
Definition: Profiler2.h:357
u8 HoldType()
Definition: Profiler2.cpp:424
std::string m_Name
Definition: Profiler2.h:220
double m_Limit
Definition: Profiler2.h:491
void RecordRegionEnter(const char *id)
Definition: Profiler2.h:347
Scope-based enter/leave helper.
Definition: Profiler2.h:499
void Shutdown()
Call in main thread to shut everything down.
Definition: Profiler2.cpp:247
mg_context * m_MgContext
Definition: Profiler2.h:451
double m_LastTime
Definition: Profiler2.h:222
Used by CProfiler2 for GPU profiling support.
Definition: Profiler2GPU.h:33
Definition: Profiler2.h:112
void RecordGPUFrameStart()
Definition: Profiler2.cpp:265
CProfiler2GPU * m_GPU
Definition: Profiler2.h:453
void EnableGPU()
Call in main thread to enable the GPU profiling support, after OpenGL has been initialised.
Definition: Profiler2.cpp:206
~CProfiler2()
Definition: Profiler2.cpp:62
double m_StartTime
Definition: Profiler2.h:507
~CProfile2GPURegion()
Definition: Profiler2.h:521
void StopHoldingMessages(bool writeToBuffer, bool condensed=false)
Definition: Profiler2.h:393
void Toggle()
Call in main thread to enable/disable the profiler.
Definition: Profiler2.cpp:232
void RecordEvent(const char *id)
Definition: Profiler2.h:342
void RemoveThreadStorage(ThreadStorage *storage)
Definition: Profiler2.cpp:309
float dt
Definition: Profiler2.h:125
Definition: Profiler2.h:111
size_t m_HeldDepth
Definition: Profiler2.h:254
CProfiler2()
Definition: Profiler2.cpp:57
double m_StartTime
Definition: Profiler2.h:492
static const size_t MAX_ATTRIBUTE_LENGTH
Definition: Profiler2.h:115
friend class CProfile2SpikeRegion
Definition: Profiler2.h:99
void InitialiseGPU()
Definition: Profiler2.cpp:171
void RecordGPUFrameEnd()
Definition: Profiler2.cpp:271
Scope-based GPU enter/leave helper.
Definition: Profiler2.h:514
void ConstructJSONOverview(std::ostream &stream)
Call in any thread to produce a JSON representation of the general state of the application.
Definition: Profiler2.cpp:731
bool m_PushedHold
Definition: Profiler2.h:508
u32 m_BufferPos1
Definition: Profiler2.h:268
void RecordSyncMarker()
Non-main threads should call this occasionally, especially if it's been a long time since their last ...
Definition: Profiler2.h:328
Definition: mongoose.cpp:489
An item with a relative time and an ID string pointer.
Definition: Profiler2.h:123
~HoldBuffer()
Definition: Profiler2.h:236
void HoldMessages(u8 type)
Definition: Profiler2.h:388
int GetFrameNumber()
Definition: Profiler2.h:425
Class instantiated in every registered thread.
Definition: Profiler2.h:137
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:906
void RecordFrameStart(double t)
Definition: Profiler2.h:166