-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf_hooks: use arrays to store EntryBuffers
Also order entries by startTime when calling getEntriesByType. Fix: #42004 Fix: #42024 PR-URL: #42032 Fixes: #42004 Fixes: #42024 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
- Loading branch information
1 parent
c47b436
commit b7a307f
Showing
3 changed files
with
59 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// This file may needs to be updated to wpt: | ||
// https://github.com/web-platform-tests/wpt | ||
|
||
import '../common/index.mjs'; | ||
import assert from 'assert'; | ||
|
||
import { performance } from 'perf_hooks'; | ||
import { setTimeout } from 'timers/promises'; | ||
|
||
// Order by startTime | ||
performance.mark('one'); | ||
await setTimeout(50); | ||
performance.mark('two'); | ||
await setTimeout(50); | ||
performance.mark('three'); | ||
await setTimeout(50); | ||
performance.measure('three', 'three'); | ||
await setTimeout(50); | ||
performance.measure('two', 'two'); | ||
await setTimeout(50); | ||
performance.measure('one', 'one'); | ||
const entries = performance.getEntriesByType('measure'); | ||
assert.deepStrictEqual(entries.map((x) => x.name), ['one', 'two', 'three']); | ||
const allEntries = performance.getEntries(); | ||
assert.deepStrictEqual(allEntries.map((x) => x.name), ['one', 'one', 'two', 'two', 'three', 'three']); | ||
|
||
performance.mark('a'); | ||
await setTimeout(50); | ||
performance.measure('a', 'a'); | ||
await setTimeout(50); | ||
performance.mark('a'); | ||
await setTimeout(50); | ||
performance.measure('a', 'one'); | ||
const entriesByName = performance.getEntriesByName('a'); | ||
assert.deepStrictEqual(entriesByName.map((x) => x.entryType), ['measure', 'mark', 'measure', 'mark']); |