Skip to content

Commit

Permalink
perf_hooks: implementation of the perf timing API
Browse files Browse the repository at this point in the history
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 <matteo.collina@gmail.com>
  • Loading branch information
jasnell authored and MylesBorins committed Sep 11, 2017
1 parent 12245ae commit 0258f45
Show file tree
Hide file tree
Showing 21 changed files with 2,381 additions and 7 deletions.
1 change: 1 addition & 0 deletions doc/api/_toc.md
Expand Up @@ -32,6 +32,7 @@
* [Net](net.html)
* [OS](os.html)
* [Path](path.html)
* [Performance Hooks](perf_hooks.html)
* [Process](process.html)
* [Punycode](punycode.html)
* [Query Strings](querystring.html)
Expand Down
1 change: 1 addition & 0 deletions doc/api/all.md
Expand Up @@ -27,6 +27,7 @@
@include net
@include os
@include path
@include perf_hooks
@include process
@include punycode
@include querystring
Expand Down

0 comments on commit 0258f45

Please sign in to comment.