From 9e509b622bbdc14b7153d006f57043f268017138 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 14 Feb 2018 11:06:32 -0800 Subject: 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 Reviewed-By: Matteo Collina --- src/tracing/trace_event.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/tracing') diff --git a/src/tracing/trace_event.h b/src/tracing/trace_event.h index 4aac9e5543..3fbe1b0a1f 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) \ -- cgit v1.2.3