-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf_hooks: allow omitted parameters in 'performance.measure'
Make `startMark` and `endMark` parameters optional. PR-URL: #32651 Fixes: #32647 Refs: https://www.w3.org/TR/user-timing-2/#measure-method Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
Showing
4 changed files
with
56 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
const { PerformanceObserver, performance } = require('perf_hooks'); | ||
const DELAY = 1000; | ||
|
||
const expected = ['Start to Now', 'A to Now', 'A to B']; | ||
const obs = new PerformanceObserver(common.mustCall((items) => { | ||
const entries = items.getEntries(); | ||
const { name, duration } = entries[0]; | ||
assert.ok(duration > DELAY); | ||
assert.strictEqual(expected.shift(), name); | ||
}, 3)); | ||
obs.observe({ entryTypes: ['measure'] }); | ||
|
||
performance.mark('A'); | ||
setTimeout(common.mustCall(() => { | ||
performance.measure('Start to Now'); | ||
performance.measure('A to Now', 'A'); | ||
|
||
performance.mark('B'); | ||
performance.measure('A to B', 'A', 'B'); | ||
}), DELAY); |