-
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: add toJSON to performance class
Added toJSON method to the InternalPerformance class as per the convention followed in other performance classes and per the spec: https://www.w3.org/TR/hr-time/#tojson-method Fixes: #37623 PR-URL: #37771 Fixes: #37623 Reviewed-By: James M Snell <[email protected]>
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 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,14 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const { performance } = require('perf_hooks'); | ||
|
||
// Test toJSON for performance object | ||
{ | ||
assert.strictEqual(typeof performance.toJSON, 'function'); | ||
const jsonObject = performance.toJSON(); | ||
assert.strictEqual(typeof jsonObject, 'object'); | ||
assert.strictEqual(jsonObject.timeOrigin, performance.timeOrigin); | ||
assert.strictEqual(typeof jsonObject.nodeTiming, 'object'); | ||
} |