From 96cb4fb795808aa2774e842974aeb411c5d3dd94 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Tue, 6 Mar 2018 10:42:37 -0800 Subject: perf_hooks,trace_events: emit perf milestone trace events Emit the perf_hooks node timing milestones as trace events. PR-URL: https://github.com/nodejs/node/pull/19175 Reviewed-By: Anna Henningsen --- src/node_perf.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/node_perf.cc') diff --git a/src/node_perf.cc b/src/node_perf.cc index 8260d78c32..8b476890e1 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -40,6 +40,15 @@ uint64_t performance_v8_start; uint64_t performance_last_gc_start_mark_ = 0; v8::GCType performance_last_gc_type_ = v8::GCType::kGCTypeAll; +void performance_state::Mark(enum PerformanceMilestone milestone, + uint64_t ts) { + this->milestones[milestone] = ts; + TRACE_EVENT_INSTANT_WITH_TIMESTAMP0( + TRACING_CATEGORY_NODE1(bootstrap), + GetPerformanceMilestoneName(milestone), + TRACE_EVENT_SCOPE_THREAD, ts); +} + double GetCurrentTimeInMicroseconds() { #ifdef _WIN32 // The difference between the Unix Epoch and the Windows Epoch in 100-ns ticks. @@ -200,14 +209,11 @@ void Measure(const FunctionCallbackInfo& args) { void MarkMilestone(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Local context = env->context(); - AliasedBuffer& milestones = - env->performance_state()->milestones; PerformanceMilestone milestone = static_cast( args[0]->Int32Value(context).ToChecked()); - if (milestone != NODE_PERFORMANCE_MILESTONE_INVALID) { - milestones[milestone] = PERFORMANCE_NOW(); - } + if (milestone != NODE_PERFORMANCE_MILESTONE_INVALID) + env->performance_state()->Mark(milestone); } -- cgit v1.2.3