15 #ifndef INSTRUMENTOR_H
16 #define INSTRUMENTOR_H
33 # define BEGIN_PROFILING_SESSION(name, storeInMemory, outputPath) Instrumentor::get().beginSession(name, storeInMemory, outputPath)
34 # define END_PROFILING_SESSION Instrumentor::get().endSession()
35 # define PROFILE_SCOPE(name) InstrumentationTimer timer##__LINE__(name)
36 # define PROFILE_FUNCTION() PROFILE_SCOPE(__FUNCTION__)
38 # define BEGIN_PROFILING_SESSION(name, storeInMemory, outputPath)
39 # define END_PROFILING_SESSION
40 # define PROFILE_SCOPE(name)
41 # define PROFILE_FUNCTION()
83 const bool storeInMemory =
false,
84 const std::string&
filePath =
"Profiling-Results.json")
121 std::lock_guard<std::mutex> lock(
_mutex);
138 std::string name = result.
name;
139 std::replace(name.begin(), name.end(),
'"',
'\'');
205 auto endTimepoint = std::chrono::high_resolution_clock::now();
207 long long start = std::chrono::time_point_cast<std::chrono::microseconds>(
_startTimepoint).time_since_epoch().count();
208 long long end = std::chrono::time_point_cast<std::chrono::microseconds>(endTimepoint).time_since_epoch().count();
210 uint32_t threadID = (uint32_t)std::hash<std::thread::id>{}(std::this_thread::get_id());
224 #endif INSTRUMENTER_H
std::chrono::high_resolution_clock::time_point HighResTimePoint
std::chrono::time_point< std::chrono::high_resolution_clock > HighResTimePoint
bool _isStopped
flag if timer got stopped
HighResTimePoint _startTimepoint
start timepoint
const char * _name
function or scope name as char pointer (not std::string)
InstrumentationTimer(const char *name)
Basic instrumentation profiler for Google Chrome tracing format.
std::ofstream _outputStream
void addProfile(const ProfileResult &result)
void beginSession(const std::string &name, const bool storeInMemory=false, const std::string &filePath="Profiling-Results.json")
std::vector< ProfileResult > _profileResults
static Instrumentor & get()
void writeProfile(const ProfileResult &result)
InstrumentationSession * _currentSession
long long end
end time point
long long start
start time point
uint32_t threadID
thread ID
const char * name
pointer to char has constant length