diff options
author | himself65 <himself65@outlook.com> | 2020-04-04 11:41:34 +0300 |
---|---|---|
committer | himself65 <himself65@outlook.com> | 2020-04-10 13:08:30 +0300 |
commit | d0a3bf1f115a619ffcd8804d5b006555433af13b (patch) | |
tree | 39ab63a158409627b7e32c6347fb39796e34ff67 /doc/api/perf_hooks.md | |
parent | 4076e043b895233fb3c0060980eaab6bb74358a9 (diff) |
perf_hooks: allow omitted parameters in 'performance.measure'
Make `startMark` and `endMark` parameters optional.
PR-URL: https://github.com/nodejs/node/pull/32651
Fixes: https://github.com/nodejs/node/issues/32647
Refs: https://www.w3.org/TR/user-timing-2/#measure-method
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc/api/perf_hooks.md')
-rw-r--r-- | doc/api/perf_hooks.md | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index 00b52d96889..ac5aa2ccea0 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -17,9 +17,12 @@ const obs = new PerformanceObserver((items) => { performance.clearMarks(); }); obs.observe({ entryTypes: ['measure'] }); +performance.measure('Start to Now'); performance.mark('A'); doSomeLongRunningProcess(() => { + performance.measure('A to Now', 'A'); + performance.mark('B'); performance.measure('A to B', 'A', 'B'); }); @@ -53,14 +56,18 @@ Creates a new `PerformanceMark` entry in the Performance Timeline. A `performanceEntry.duration` is always `0`. Performance marks are used to mark specific significant moments in the Performance Timeline. -### `performance.measure(name, startMark, endMark)` +### `performance.measure(name[, startMark[, endMark]])` <!-- YAML added: v8.5.0 +changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/32651 + description: Make `startMark` and `endMark` parameters optional. --> * `name` {string} -* `startMark` {string} -* `endMark` {string} +* `startMark` {string} Optional. +* `endMark` {string} Optional. Creates a new `PerformanceMeasure` entry in the Performance Timeline. A `PerformanceMeasure` is a subclass of `PerformanceEntry` whose @@ -73,9 +80,10 @@ Performance Timeline, or *may* identify any of the timestamp properties provided by the `PerformanceNodeTiming` class. If the named `startMark` does not exist, then `startMark` is set to [`timeOrigin`][] by default. -The `endMark` argument must identify any *existing* `PerformanceMark` in the -Performance Timeline or any of the timestamp properties provided by the -`PerformanceNodeTiming` class. If the named `endMark` does not exist, an +The optional `endMark` argument must identify any *existing* `PerformanceMark` +in the Performance Timeline or any of the timestamp properties provided by the +`PerformanceNodeTiming` class. `endMark` will be `performance.now()` +if no parameter is passed, otherwise if the named `endMark` does not exist, an error will be thrown. ### `performance.nodeTiming` |