28 # define BEGIN_PROFILING_SESSION(filePath) Profiler::instance().beginSession(filePath)
29 # define PROFILE_SCOPE(name) ProfilerTimer profilerTimer##__LINE__(name)
30 # define PROFILE_FUNCTION() PROFILE_SCOPE(__FUNCTION__)
31 # define PROFILE_THREAD(name) Profiler::instance().profileThread(name)
32 # define PROFILER_TRACE_FILE_PATH Profiler::instance().filePath()
33 # define END_PROFILING_SESSION() Profiler::instance().endSession()
35 # define BEGIN_PROFILING_SESSION(filePath)
36 # define PROFILE_SCOPE(name)
37 # define PROFILE_FUNCTION()
38 # define PROFILE_THREAD(name)
39 # define PROFILER_TRACE_FILE_PATH
40 # define END_PROFILING_SESSION()
84 static void writeString(
const char*
s, std::ofstream& stream);
116 std::chrono::time_point<std::chrono::high_resolution_clock>
_startPoint;
Utility for profiling functions/scopes and writing the results to a file.
static Profiler & instance()
std::string _filePath
Future path of the trace file.
std::vector< std::string > _threadNames
List of thread names (the thread ID is the index)
std::vector< ProfilingResult > _results
List of profiling results (of all threads)
void profileThread(const std::string &name)
uint64_t _sessionStart
Start timestamp of the session in microseconds.
static void writeString(const char *s, std::ofstream &stream)
Writes the length (32-bit) and the string (non-null-terminated) itself to the file stream.
void recordResult(ProfilingResult result)
std::mutex _mutex
Mutex for accessing profiling results and thread names.
void beginSession(std::string filePath)
A timer for profiling functions and scopes.
std::chrono::time_point< std::chrono::high_resolution_clock > _startPoint
ProfilerTimer(const char *name)
static thread_local uint32_t threadId
static thread_local uint32_t threadDepth
static constexpr uint32_t INVALID_THREAD_ID
The SLScene class represents the top level instance holding the scene structure.
uint64_t end
End time in microseconds relative to the session start.
uint64_t start
Start time in microseconds relative to the session start.
uint32_t depth
Depth of the scope in it's thread's call stack.
const char * name
Name of the profiled function/scope.
uint32_t threadId
ID of the thread in which the scope was entered.