35 #define INTERNAL_MINITRACE_BUFFER_SIZE 1000000 43 void mtr_init(
const char *json_file);
83 #define MTR_MAX_ARGS 1 96 #define MTR_BEGIN(c, n) internal_mtr_raw_event(c, n, 'B', nullptr) 97 #define MTR_END(c, n) internal_mtr_raw_event(c, n, 'E', nullptr) 98 #define MTR_SCOPE(c, n) MTRScopedTrace ____mtr_scope(c, n) 99 #define MTR_SCOPE_LIMIT(c, n, l) MTRScopedTraceLimit ____mtr_scope(c, n, l) 102 #define MTR_START(c, n, id) internal_mtr_raw_event(c, n, 'S', (void *)(id)) 103 #define MTR_STEP(c, n, id, step) internal_mtr_raw_event_arg(c, n, 'T', (void *)(id), MTR_ARG_TYPE_STRING_CONST, "step", (void *)(step)) 104 #define MTR_FINISH(c, n, id) internal_mtr_raw_event(c, n, 'F', (void *)(id)) 107 #define MTR_FLOW_START(c, n, id) internal_mtr_raw_event(c, n, 's', (void *)(id)) 108 #define MTR_FLOW_STEP(c, n, id, step) internal_mtr_raw_event_arg(c, n, 't', (void *)(id), MTR_ARG_TYPE_STRING_CONST, "step", (void *)(step)) 109 #define MTR_FLOW_FINISH(c, n, id) internal_mtr_raw_event(c, n, 'f', (void *)(id)) 118 #define MTR_BEGIN_C(c, n, aname, astrval) internal_mtr_raw_event_arg(c, n, 'B', 0, MTR_ARG_TYPE_STRING_CONST, aname, (void *)(astrval)) 119 #define MTR_END_C(c, n, aname, astrval) internal_mtr_raw_event_arg(c, n, 'E', 0, MTR_ARG_TYPE_STRING_CONST, aname, (void *)(astrval)) 120 #define MTR_SCOPE_C(c, n, aname, astrval) MTRScopedTraceArg ____mtr_scope(c, n, MTR_ARG_TYPE_STRING_CONST, aname, (void *)(astrval)) 122 #define MTR_BEGIN_S(c, n, aname, astrval) internal_mtr_raw_event_arg(c, n, 'B', 0, MTR_ARG_TYPE_STRING_COPY, aname, (void *)(astrval)) 123 #define MTR_END_S(c, n, aname, astrval) internal_mtr_raw_event_arg(c, n, 'E', 0, MTR_ARG_TYPE_STRING_COPY, aname, (void *)(astrval)) 124 #define MTR_SCOPE_S(c, n, aname, astrval) MTRScopedTraceArg ____mtr_scope(c, n, MTR_ARG_TYPE_STRING_COPY, aname, (void *)(astrval)) 126 #define MTR_BEGIN_I(c, n, aname, aintval) internal_mtr_raw_event_arg(c, n, 'B', 0, MTR_ARG_TYPE_INT, aname, (void*)(intptr_t)(aintval)) 127 #define MTR_END_I(c, n, aname, aintval) internal_mtr_raw_event_arg(c, n, 'E', 0, MTR_ARG_TYPE_INT, aname, (void*)(intptr_t)(aintval)) 128 #define MTR_SCOPE_I(c, n, aname, aintval) MTRScopedTraceArg ____mtr_scope(c, n, MTR_ARG_TYPE_INT, aname, (void*)(intptr_t)(aintval)) 131 #define MTR_INSTANT(c, n) internal_mtr_raw_event(c, n, 'I', nullptr) 132 #define MTR_INSTANT_C(c, n, aname, astrval) internal_mtr_raw_event(c, n, 'I', 0, MTR_ARG_TYPE_STRING_CONST, aname, (void *)(astrval)) 133 #define MTR_INSTANT_I(c, n, aname, aintval) internal_mtr_raw_event(c, n, 'I', 0, MTR_ARG_TYPE_INT, aname, (void *)(aintval)) 136 #define MTR_COUNTER(c, n, val) internal_mtr_raw_event_arg(c, n, 'C', 0, MTR_ARG_TYPE_INT, n, (void *)(intptr_t)(val)) 140 #define MTR_META_PROCESS_NAME(n) internal_mtr_raw_event_arg("", "process_name", 'M', 0, MTR_ARG_TYPE_STRING_COPY, "name", (void *)(n)) 141 #define MTR_META_THREAD_NAME(n) internal_mtr_raw_event_arg("", "thread_name", 'M', 0, MTR_ARG_TYPE_STRING_COPY, "name", (void *)(n)) 142 #define MTR_META_THREAD_SORT_INDEX(i) internal_mtr_raw_event_arg("", "thread_sort_index", 'M', 0, MTR_ARG_TYPE_INT, "sort_index", (void *)(i)) 146 #define MTR_BEGIN(c, n) 147 #define MTR_END(c, n) 148 #define MTR_SCOPE(c, n) 149 #define MTR_START(c, n, id) 150 #define MTR_STEP(c, n, id, step) 151 #define MTR_FINISH(c, n, id) 152 #define MTR_FLOW_START(c, n, id) 153 #define MTR_FLOW_STEP(c, n, id, step) 154 #define MTR_FLOW_FINISH(c, n, id) 155 #define MTR_INSTANT(c, n) 157 #define MTR_BEGIN_C(c, n, aname, astrval) 158 #define MTR_END_C(c, n, aname, astrval) 159 #define MTR_SCOPE_C(c, n, aname, astrval) 161 #define MTR_BEGIN_S(c, n, aname, astrval) 162 #define MTR_END_S(c, n, aname, astrval) 163 #define MTR_SCOPE_S(c, n, aname, astrval) 165 #define MTR_BEGIN_I(c, n, aname, aintval) 166 #define MTR_END_I(c, n, aname, aintval) 167 #define MTR_SCOPE_I(c, n, aname, aintval) 169 #define MTR_INSTANT(c, n) 170 #define MTR_INSTANT_C(c, n, aname, astrval) 171 #define MTR_INSTANT_I(c, n, aname, aintval) 174 #define MTR_COUNTER(c, n, val) 178 #define MTR_META_PROCESS_NAME(n) 180 #define MTR_META_THREAD_NAME(n) 181 #define MTR_META_THREAD_SORT_INDEX(i) 187 #define MTR_BEGIN_FUNC() MTR_BEGIN(__FILE__, __FUNCTION__) 188 #define MTR_END_FUNC() MTR_END(__FILE__, __FUNCTION__) 189 #define MTR_SCOPE_FUNC() MTR_SCOPE(__FILE__, __FUNCTION__) 190 #define MTR_INSTANT_FUNC() MTR_INSTANT(__FILE__, __FUNCTION__) 191 #define MTR_SCOPE_FUNC_LIMIT_S(l) MTRScopedTraceLimit ____mtr_scope(__FILE__, __FUNCTION__, l) 192 #define MTR_SCOPE_FUNC_LIMIT_MS(l) MTRScopedTraceLimit ____mtr_scope(__FILE__, __FUNCTION__, 1) 195 #define MTR_BEGIN_FUNC_S(aname, arg) MTR_BEGIN_S(__FILE__, __FUNCTION__, aname, arg) 196 #define MTR_END_FUNC_S(aname, arg) MTR_END_S(__FILE__, __FUNCTION__, aname, arg) 197 #define MTR_SCOPE_FUNC_S(aname, arg) MTR_SCOPE_S(__FILE__, __FUNCTION__, aname, arg) 199 #define MTR_BEGIN_FUNC_C(aname, arg) MTR_BEGIN_C(__FILE__, __FUNCTION__, aname, arg) 200 #define MTR_END_FUNC_C(aname, arg) MTR_END_C(__FILE__, __FUNCTION__, aname, arg) 201 #define MTR_SCOPE_FUNC_C(aname, arg) MTR_SCOPE_C(__FILE__, __FUNCTION__, aname, arg) 203 #define MTR_BEGIN_FUNC_I(aname, arg) MTR_BEGIN_I(__FILE__, __FUNCTION__, aname, arg) 204 #define MTR_END_FUNC_I(aname, arg) MTR_END_I(__FILE__, __FUNCTION__, aname, arg) 205 #define MTR_SCOPE_FUNC_I(aname, arg) MTR_SCOPE_I(__FILE__, __FUNCTION__, aname, arg)
void mtr_register_sigint_handler()
void mtr_init(const char *json_file)
MTRScopedTraceLimit(const char *category, const char *name, double limit_s)
void internal_mtr_raw_event_arg(const char *category, const char *name, char ph, void *id, mtr_arg_type arg_type, const char *arg_name, void *arg_value)
MTRScopedTraceArg(const char *category, const char *name, mtr_arg_type arg_type, const char *arg_name, void *arg_value)
MTRScopedTrace(const char *category, const char *name)
void internal_mtr_raw_event(const char *category, const char *name, char ph, void *id)
const char * mtr_pool_string(const char *str)