From 67269fd7f33279699b1ae71225f3d738518c844c Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 7 Aug 2017 15:53:24 -0700 Subject: perf_hooks: implementation of the perf timing API An initial implementation of the Performance Timing API for Node.js. This is the same Performance Timing API implemented by modern browsers with a number of Node.js specific properties. The User Timing mark() and measure() APIs are implemented, garbage collection timing, and node startup milestone timing. ```js const { performance } = require('perf_hooks'); performance.mark('A'); setTimeout(() => { performance.mark('B'); performance.measure('A to B', 'A', 'B'); const entry = performance.getEntriesByName('A to B', 'measure')[0]; console.log(entry.duration); }, 10000); ``` The implementation is at the native layer and makes use of uv_hrtime(). This should enable *eventual* integration with things like Tracing and Inspection. The implementation is extensible and should allow us to add new performance entry types as we go (e.g. for measuring i/o perf, etc). Documentation and a test are provided. PR-URL: https://github.com/nodejs/node/pull/14680 Reviewed-By: Matteo Collina --- src/node_internals.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/node_internals.h') diff --git a/src/node_internals.h b/src/node_internals.h index 5d437fa302..1e099325a3 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -30,6 +30,7 @@ #include "uv.h" #include "v8.h" #include "tracing/trace_event.h" +#include "node_perf_common.h" #include "node_debug_options.h" #include -- cgit v1.2.3