Skip to content

Commit 551aa74

Browse files
committed
perf: 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: nodejs#37623
1 parent 8e8dea3 commit 551aa74

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/perf_hooks.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ class Performance extends EventTarget {
5959
timeOrigin: this.timeOrigin,
6060
}, opts)}`;
6161
}
62+
63+
toJSON() {
64+
return {
65+
nodeTiming: this.nodeTiming.toJSON(),
66+
timeOrigin: this.timeOrigin,
67+
eventLoopUtilization: this.eventLoopUtilization()
68+
};
69+
}
6270
}
6371

6472
class InternalPerformance extends EventTarget {}
@@ -114,7 +122,7 @@ module.exports = {
114122
PerformanceObserver,
115123
monitorEventLoopDelay,
116124
createHistogram,
117-
performance: new InternalPerformance(),
125+
performance: new InternalPerformance()
118126
};
119127

120128
ObjectDefineProperty(module.exports, 'constants', {

0 commit comments

Comments
 (0)