| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 460240c commit 1e9ff50
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -136,6 +136,16 @@ class PerformanceMeasure extends PerformanceEntry { | |||
| 136 | 136 | validateInternalField(this, kDetail, 'PerformanceMeasure'); | |
| 137 | 137 | return this[kDetail]; | |
| 138 | 138 | } | |
| 139 | + | ||
| 140 | + toJSON() { | ||
| 141 | + return { | ||
| 142 | + name: this.name, | ||
| 143 | + entryType: this.entryType, | ||
| 144 | + startTime: this.startTime, | ||
| 145 | + duration: this.duration, | ||
| 146 | + detail: this[kDetail], | ||
| 147 | + }; | ||
| 148 | + } | ||
| 139 | 149 | } | |
| 140 | 150 | ObjectDefineProperties(PerformanceMeasure.prototype, { | |
| 141 | 151 | detail: kEnumerableProperty, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const util = require('util'); | ||
| 6 | + const { performance, PerformanceObserver } = require('perf_hooks'); | ||
| 7 | + | ||
| 8 | + const perfObserver = new PerformanceObserver(common.mustCall((items) => { | ||
| 9 | + const entries = items.getEntries(); | ||
| 10 | + assert.ok(entries.length === 1); | ||
| 11 | + for (const entry of entries) { | ||
| 12 | + assert.ok(util.inspect(entry).includes('this is detail')); | ||
| 13 | + } | ||
| 14 | + })); | ||
| 15 | + | ||
| 16 | + perfObserver.observe({ entryTypes: ['measure'] }); | ||
| 17 | + | ||
| 18 | + performance.measure('sample', { | ||
| 19 | + detail: 'this is detail', | ||
| 20 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments