Vesper 0.5.1
Vesper is short form for the Latin word for "Bat", as Vesper is designed to be small, lightweight, and easily handle things like particles and flocking behaviors in accordance with the nature of bats. \n It is meant to be a particle simulation, VFX editor, and CAN be used secondarily as a small game engine.
GitHub | Vesper Updates | Creator
Loading...
Searching...
No Matches
Vesper::Instrumentor Class Reference

#include <Instrumentor.h>

Public Member Functions

 Instrumentor ()
void BeginSession (const std::string &name, const std::string &filepath="results.json")
void EndSession ()
void WriteProfile (const ProfileResult &result)
void WriteHeader ()
void WriteFooter ()
void InternalEndSession ()

Static Public Member Functions

static InstrumentorGet ()

Private Attributes

InstrumentationSessionm_CurrentSession
std::ofstream m_OutputStream
std::mutex m_Mutex

Constructor & Destructor Documentation

◆ Instrumentor()

Vesper::Instrumentor::Instrumentor ( )
inline
54 : m_CurrentSession(nullptr)
55 {
56 }
InstrumentationSession * m_CurrentSession
Definition Instrumentor.h:49

Member Function Documentation

◆ BeginSession()

void Vesper::Instrumentor::BeginSession ( const std::string & name,
const std::string & filepath = "results.json" )
inline
59 {
60 std::lock_guard lock(m_Mutex);
61 if (m_CurrentSession) {
62 // If there is already a current session, end it and start new one
63 if (Log::GetCoreLogger())
64 {
65 VZ_CORE_ERROR("Instrumentor::BeginSession('{0}') when session '{1}' already open.", name, m_CurrentSession->Name);
66 }
68 }
69 m_OutputStream.open(filepath);
70 if (m_OutputStream.is_open()) {
71 m_CurrentSession = new InstrumentationSession{ name };
73 }
74 else {
75 if (Log::GetCoreLogger())
76 {
77 VZ_CORE_ERROR("Instrumentor could not open results file '{0}'.", filepath);
78 }
79 }
81 m_CurrentSession = new InstrumentationSession{ name };
82 }
#define VZ_CORE_ERROR(...)
error: indicates an error that has occurred
Definition Log.h:41
std::ofstream m_OutputStream
Definition Instrumentor.h:50
void WriteHeader()
Definition Instrumentor.h:115
std::mutex m_Mutex
Definition Instrumentor.h:51
void InternalEndSession()
Definition Instrumentor.h:127
static std::shared_ptr< spdlog::logger > & GetCoreLogger()
Returns the core logger instance.
Definition Log.h:23

◆ EndSession()

void Vesper::Instrumentor::EndSession ( )
inline
85 {
86 std::lock_guard lock(m_Mutex);
88 }

◆ Get()

Instrumentor & Vesper::Instrumentor::Get ( )
inlinestatic
139 {
140 static Instrumentor instance;
141 return instance;
142 }
Instrumentor()
Definition Instrumentor.h:53

◆ InternalEndSession()

void Vesper::Instrumentor::InternalEndSession ( )
inline
128 {
130 {
131 WriteFooter();
132 m_OutputStream.close();
133 delete m_CurrentSession;
134 m_CurrentSession = nullptr;
135 }
136 }
void WriteFooter()
Definition Instrumentor.h:121

◆ WriteFooter()

void Vesper::Instrumentor::WriteFooter ( )
inline
122 {
123 m_OutputStream << "]}";
124 m_OutputStream.flush();
125 }

◆ WriteHeader()

void Vesper::Instrumentor::WriteHeader ( )
inline
116 {
117 m_OutputStream << "{\"otherData\": {},\"traceEvents\":[";
118 m_OutputStream.flush();
119 }

◆ WriteProfile()

void Vesper::Instrumentor::WriteProfile ( const ProfileResult & result)
inline
91 {
92 m_OutputStream << ",";
93
94 std::string name = result.Name;
95 std::replace(name.begin(), name.end(), '"', '\'');
96
97 m_OutputStream << "{";
98 m_OutputStream << "\"cat\":\"function\",";
99 m_OutputStream << "\"dur\":" << (result.End - result.Start) << ',';
100 m_OutputStream << "\"name\":\"" << name << "\",";
101 m_OutputStream << "\"ph\":\"X\",";
102 m_OutputStream << "\"pid\":0,";
103 m_OutputStream << "\"tid\":" << result.ThreadID << ",";
104 m_OutputStream << "\"ts\":" << result.Start;
105 m_OutputStream << "}";
106
107 std::lock_guard lock(m_Mutex);
109 {
110 //m_OutputStream << json.str();
111 m_OutputStream.flush();
112 }
113 }

Member Data Documentation

◆ m_CurrentSession

InstrumentationSession* Vesper::Instrumentor::m_CurrentSession
private

◆ m_Mutex

std::mutex Vesper::Instrumentor::m_Mutex
private

◆ m_OutputStream

std::ofstream Vesper::Instrumentor::m_OutputStream
private

The documentation for this class was generated from the following file: