1#ifndef AYONCPPAPIINSTRUMENTOR_H
2#define AYONCPPAPIINSTRUMENTOR_H
33 void BeginSession(
const std::string &name,
const std::string &filepath =
"results.json") {
34 std::lock_guard<std::mutex> lock(
m_mutex);
49 std::future<void> asyncResult = std::async(std::launch::async, [
this, result]() {
WriteProfile(result); });
54 std::lock_guard<std::mutex> lock(
m_mutex);
58 std::string name = result.
name;
59 std::replace(name.begin(), name.end(),
'"',
'\'');
102 auto endTimepoint = std::chrono::high_resolution_clock::now();
105 = std::chrono::time_point_cast<std::chrono::microseconds>(
m_startTimepoint).time_since_epoch().count();
107 = std::chrono::time_point_cast<std::chrono::microseconds>(endTimepoint).time_since_epoch().count();
109 uint32_t threadID = std::hash<std::thread::id>{}(std::this_thread::get_id());
Definition: Instrumentor.h:90
bool m_stopped
Definition: Instrumentor.h:119
~InstrumentationTimer()
Definition: Instrumentor.h:96
const char * m_name
Definition: Instrumentor.h:117
void Stop()
Definition: Instrumentor.h:101
std::chrono::time_point< std::chrono::high_resolution_clock > m_startTimepoint
Definition: Instrumentor.h:118
InstrumentationTimer(const char *name)
Definition: Instrumentor.h:92
Definition: Instrumentor.h:22
void endSession()
Definition: Instrumentor.h:40
static Instrumentor & Get()
Definition: Instrumentor.h:84
void WriteProfile(const ProfileResult &result)
Definition: Instrumentor.h:53
std::mutex m_mutex
Definition: Instrumentor.h:27
InstrumentationSession * m_currentSession
Definition: Instrumentor.h:24
int m_profileCount
Definition: Instrumentor.h:26
void WriteFooter()
Definition: Instrumentor.h:79
std::ofstream m_outputStream
Definition: Instrumentor.h:25
void WriteHeader()
Definition: Instrumentor.h:74
Instrumentor()
Definition: Instrumentor.h:30
void WriteProfileAsync(const ProfileResult &result)
Definition: Instrumentor.h:48
void BeginSession(const std::string &name, const std::string &filepath="results.json")
Definition: Instrumentor.h:33
Definition: Instrumentor.h:18
std::string name
Definition: Instrumentor.h:19
Definition: Instrumentor.h:12
long long end
Definition: Instrumentor.h:14
std::string name
Definition: Instrumentor.h:13
long long start
Definition: Instrumentor.h:14
uint32_t threadID
Definition: Instrumentor.h:15