| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9258604 commit 4711f57
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -261,6 +261,14 @@ If the wrapped function returns a promise, a finally handler will be attached | |||
| 261 | 261 | to the promise and the duration will be reported once the finally handler is | |
| 262 | 262 | invoked. | |
| 263 | 263 | ||
| 264 | + ### `performance.toJSON()` | ||
| 265 | + <!-- YAML | ||
| 266 | + added: REPLACEME | ||
| 267 | + --> | ||
| 268 | + | ||
| 269 | + An object which is JSON representation of the `performance` object. It | ||
| 270 | + is similar to [`window.performance.toJSON`][] in browsers. | ||
| 271 | + | ||
| 264 | 272 | ## Class: `PerformanceEntry` | |
| 265 | 273 | <!-- YAML | |
| 266 | 274 | added: v8.5.0 | |
@@ -1025,4 +1033,5 @@ require('some-module'); | |||
| 1025 | 1033 | [`child_process.spawnSync()`]: child_process.md#child_process_child_process_spawnsync_command_args_options | |
| 1026 | 1034 | [`process.hrtime()`]: process.md#process_process_hrtime_time | |
| 1027 | 1035 | [`timeOrigin`]: https://w3c.github.io/hr-time/#dom-performance-timeorigin | |
| 1036 | + [`window.performance.toJSON`]: https://developer.mozilla.org/en-US/docs/Web/API/Performance/toJSON | ||
| 1028 | 1037 | [`window.performance`]: https://developer.mozilla.org/en-US/docs/Web/API/Window/performance | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,6 +59,15 @@ class Performance extends EventTarget { | |||
| 59 | 59 | timeOrigin: this.timeOrigin, | |
| 60 | 60 | }, opts)}`; | |
| 61 | 61 | } | |
| 62 | + | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + function toJSON() { | ||
| 66 | + return { | ||
| 67 | + nodeTiming: this.nodeTiming, | ||
| 68 | + timeOrigin: this.timeOrigin, | ||
| 69 | + eventLoopUtilization: this.eventLoopUtilization() | ||
| 70 | + }; | ||
| 62 | 71 | } | |
| 63 | 72 | ||
| 64 | 73 | class InternalPerformance extends EventTarget {} | |
@@ -105,6 +114,11 @@ ObjectDefineProperties(Performance.prototype, { | |||
| 105 | 114 | configurable: true, | |
| 106 | 115 | enumerable: true, | |
| 107 | 116 | value: timeOriginTimestamp, | |
| 117 | + }, | ||
| 118 | + toJSON: { | ||
| 119 | + configurable: true, | ||
| 120 | + enumerable: true, | ||
| 121 | + value: toJSON, | ||
| 108 | 122 | } | |
| 109 | 123 | }); | |
| 110 | 124 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const { performance } = require('perf_hooks'); | ||
| 6 | + | ||
| 7 | + // Test toJSON for performance object | ||
| 8 | + { | ||
| 9 | + assert.strictEqual(typeof performance.toJSON, 'function'); | ||
| 10 | + const jsonObject = performance.toJSON(); | ||
| 11 | + assert.strictEqual(typeof jsonObject, 'object'); | ||
| 12 | + assert.strictEqual(jsonObject.timeOrigin, performance.timeOrigin); | ||
| 13 | + assert.strictEqual(typeof jsonObject.nodeTiming, 'object'); | ||
| 14 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments