一呼百應, "one call, a hundred responses"
Loading...
Searching...
No Matches
ein::profiling Namespace Reference

Classes

struct  duration_event
 
struct  profile
 
struct  profile_event
 
struct  profile_scope
 
struct  scope_event
 

Enumerations

enum class  scope : char {
  global = 'g' ,
  process = 'p' ,
  thread = 't' ,
  none = '\0'
}
 
enum  event_type : char {
  duration_begin = 'B' ,
  duration_end = 'E' ,
  complete = 'X' ,
  instant = 'i' ,
  counter = 'C' ,
  async_start = 'b' ,
  async_instant = 'n' ,
  async_end = 'e' ,
  flow_start = 's' ,
  flow_step = 't' ,
  flow_end = 'f' ,
  sample = 'P' ,
  object_created = 'N' ,
  object_snapshot = 'O' ,
  object_destroyed = 'D' ,
  metadata = 'M' ,
  memory_dump_global = 'V' ,
  memory_dump_local = 'v' ,
  mark = 'R' ,
  clock_sync = 'c' ,
  context_enter = '(' ,
  context_leave = ')'
}
 

Functions

template<typename Duration , typename Clock >
void to_json (nlohmann::json &j, const profile_event< Duration, Clock > &t)
 
template<typename Mutex , typename Duration , typename Clock >
void to_json (nlohmann::json &j, profile< Mutex, Duration, Clock > const &p) noexcept
 
void make_args (nlohmann::json &) noexcept
 
template<typename K , typename V , typename ... Args>
void make_args (nlohmann::json &j, K &&k, V &&v, Args &&... args)
 

Variables

template<typename T >
static constexpr char const * duration_suffix
 

Detailed Description

Todo
parameterize all of this on a couple of types that can serialize to json for flow id and for the contents of the message, rather than use nlohmann::json directly

Class Documentation

◆ ein::profiling::profile_event

struct ein::profiling::profile_event
template<typename Duration = std::chrono::nanoseconds, typename Clock = std::chrono::high_resolution_clock>
struct ein::profiling::profile_event< Duration, Clock >

Definition at line 80 of file profiling.hpp.

Collaboration diagram for ein::profiling::profile_event< Duration, Clock >:
[legend]
Class Members
typedef Clock clock Clock
typedef Duration duration Duration
Class Members
json args {}
static_c_string bp {}
static_c_string cat {}
optional< string > id {}
static_c_string name {}
event_type ph
pid_t pid = getpid()
scope s
size_t tid = std::hash<std::thread::id>{}(std::this_thread::get_id())
size_t ts = std::chrono::duration_cast<duration>(clock::now().time_since_epoch()).count()

Enumeration Type Documentation

◆ event_type

Enumerator
duration_begin 
duration_end 
complete 
instant 
counter 
async_start 
async_instant 
async_end 
flow_start 
flow_step 
flow_end 
sample 
object_created 
object_snapshot 
object_destroyed 
metadata 
memory_dump_global 
memory_dump_local 
mark 
clock_sync 
context_enter 
context_leave 

Definition at line 41 of file profiling.hpp.

41 : char {
42 duration_begin = 'B', duration_end = 'E', complete = 'X', instant = 'i',
43 counter = 'C', async_start = 'b', async_instant = 'n', async_end = 'e',
44 flow_start = 's', flow_step = 't', flow_end = 'f', sample = 'P',
47 mark = 'R', clock_sync = 'c', context_enter = '(', context_leave = ')'
48};

◆ scope

enum class ein::profiling::scope : char
strong
Enumerator
global 
process 
thread 
none 

Definition at line 25 of file profiling.hpp.

25 : char {
26 global = 'g',
27 process = 'p',
28 thread = 't',
29 none = '\0'
30};

Function Documentation

◆ make_args() [1/2]

void ein::profiling::make_args ( nlohmann::json & )
inlinenoexcept

Definition at line 319 of file profiling.hpp.

319{}

Referenced by make_args().

Here is the caller graph for this function:

◆ make_args() [2/2]

template<typename K , typename V , typename ... Args>
void ein::profiling::make_args ( nlohmann::json & j,
K && k,
V && v,
Args &&... args )
inline

Definition at line 322 of file profiling.hpp.

322 {
323 j[std::forward(k)] = std::forward(v);
324 make_args(j,std::forward<Args>(args)...);
325}
void make_args(nlohmann::json &) noexcept

References make_args().

◆ to_json() [1/2]

template<typename Duration , typename Clock >
void ein::profiling::to_json ( nlohmann::json & j,
const profile_event< Duration, Clock > & t )

Definition at line 96 of file profiling.hpp.

96 {
97 if (not t.name) j["name"] = t.name;
98 if (not t.cat) j["cat"] = t.cat;
99 j["ph"] = t.ph;
100 j["ts"] = t.ts;
101 j["pid"] = t.pid;
102 j["tid"] = t.tid;
103 if (t.s != scope::none) j["s"] = t.s;
104 if (t.id.has_value()) j["id"] = *t.id;
105 if (t.bp) j["bp"] = t.bp;
106 if (not t.args.is_null()) j["args"] = t.args;
107}
std::optional< string > id
Definition profiling.hpp:90

References ein::profiling::profile_event< Duration, Clock >::args, ein::profiling::profile_event< Duration, Clock >::bp, ein::profiling::profile_event< Duration, Clock >::cat, ein::profiling::profile_event< Duration, Clock >::id, ein::profiling::profile_event< Duration, Clock >::name, none, ein::profiling::profile_event< Duration, Clock >::ph, ein::profiling::profile_event< Duration, Clock >::pid, ein::profiling::profile_event< Duration, Clock >::s, ein::profiling::profile_event< Duration, Clock >::tid, and ein::profiling::profile_event< Duration, Clock >::ts.

◆ to_json() [2/2]

template<typename Mutex , typename Duration , typename Clock >
void ein::profiling::to_json ( nlohmann::json & j,
profile< Mutex, Duration, Clock > const & p )
noexcept[[always_inline]]

Definition at line 209 of file profiling.hpp.

209 {
210 j = {
211 {"traceEvents", p.events},
212 {"displayTimeUnit", static_cast<const char *>(duration_suffix<Duration>) }
213 };
214 if (p.metadata.is_object())
215 for (const auto &e : p.metadata.template get<nlohmann::json::object_t>())
216 j[e.first] = e.second;
217};
nlohmann::json metadata
std::vector< event > events

References duration_suffix.

Variable Documentation

◆ duration_suffix

template<typename T >
char const* ein::profiling::duration_suffix
staticconstexpr

Definition at line 76 of file profiling.hpp.

Referenced by to_json().