Skip to content

Commit f75fadd

Browse files
jasnellMylesBorins
authored andcommitted
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: #14680 Reviewed-By: Matteo Collina <[email protected]>
1 parent 8cee5d6 commit f75fadd

21 files changed

+2381
-7
lines changed

doc/api/_toc.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* [Net](net.html)
3333
* [OS](os.html)
3434
* [Path](path.html)
35+
* [Performance Hooks](perf_hooks.html)
3536
* [Process](process.html)
3637
* [Punycode](punycode.html)
3738
* [Query Strings](querystring.html)

doc/api/all.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
@include net
2828
@include os
2929
@include path
30+
@include perf_hooks
3031
@include process
3132
@include punycode
3233
@include querystring

0 commit comments

Comments
 (0)