summaryrefslogtreecommitdiff
path: root/src/node_perf.cc
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2018-03-06 10:42:37 -0800
committerJames M Snell <jasnell@gmail.com>2018-03-16 10:54:05 -0700
commit96cb4fb795808aa2774e842974aeb411c5d3dd94 (patch)
treeda8a3965240c402f857e6267e0a278f486852c3a /src/node_perf.cc
parent879f521c654fffd34360be432a6280936ba94071 (diff)
downloadandroid-node-v8-96cb4fb795808aa2774e842974aeb411c5d3dd94.tar.gz
android-node-v8-96cb4fb795808aa2774e842974aeb411c5d3dd94.tar.bz2
android-node-v8-96cb4fb795808aa2774e842974aeb411c5d3dd94.zip
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 <anna@addaleax.net>
Diffstat (limited to 'src/node_perf.cc')
-rw-r--r--src/node_perf.cc16
1 files changed, 11 insertions, 5 deletions
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<Value>& args) {
void MarkMilestone(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Local<Context> context = env->context();
- AliasedBuffer<double, v8::Float64Array>& milestones =
- env->performance_state()->milestones;
PerformanceMilestone milestone =
static_cast<PerformanceMilestone>(
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);
}