diff options
author | James M Snell <jasnell@gmail.com> | 2018-02-14 22:06:32 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2018-02-27 00:55:33 +0300 |
commit | 9e509b622bbdc14b7153d006f57043f268017138 (patch) | |
tree | 0a01cc2665342046c8c198bdff76eed869263978 /src/tracing | |
parent | aca8e764da444a9a5eb67812db2317c1c32215d9 (diff) |
perf_hooks: emit trace events for marks, measures, and timerify
Adds the `node.perf.usertiming` trace events category for recording
usertiming marks and measures (e.g. `perf_hooks.performance.mark()`)
in the trace events timeline.
Adds the `node.perf.function` trace events category for recording
`perf_hooks.performance.timerify()` durations in the trace events
timeline.
PR-URL: https://github.com/nodejs/node/pull/18789
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/tracing')
-rw-r--r-- | src/tracing/trace_event.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/tracing/trace_event.h b/src/tracing/trace_event.h index 4aac9e5543e..3fbe1b0a1f9 100644 --- a/src/tracing/trace_event.h +++ b/src/tracing/trace_event.h @@ -244,9 +244,20 @@ enum CategoryGroupEnabledFlags { // Adds a trace event with a given id, thread_id, and timestamp. Not // Implemented. -#define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ - phase, category_group, name, id, thread_id, timestamp, flags, ...) \ - UNIMPLEMENTED() +#define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ + phase, category_group, name, id, thread_id, timestamp, flags, ...) \ + do { \ + INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ + if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ + unsigned int trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ + node::tracing::TraceID trace_event_trace_id(id, \ + &trace_event_flags); \ + node::tracing::AddTraceEventWithTimestamp( \ + phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ + trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \ + node::tracing::kNoId, trace_event_flags, timestamp, ##__VA_ARGS__);\ + } \ + } while (0) // Enter and leave a context based on the current scope. #define INTERNAL_TRACE_EVENT_SCOPED_CONTEXT(category_group, name, context) \ |