File tree 2 files changed +22
-1
lines changed 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,14 @@ class Performance extends EventTarget {
59
59
timeOrigin : this . timeOrigin ,
60
60
} , opts ) } `;
61
61
}
62
+
63
+ toJSON ( ) {
64
+ return {
65
+ nodeTiming : this . nodeTiming . toJSON ( ) ,
66
+ timeOrigin : this . timeOrigin ,
67
+ eventLoopUtilization : this . eventLoopUtilization ( )
68
+ } ;
69
+ }
62
70
}
63
71
64
72
class InternalPerformance extends EventTarget { }
@@ -114,7 +122,7 @@ module.exports = {
114
122
PerformanceObserver,
115
123
monitorEventLoopDelay,
116
124
createHistogram,
117
- performance : new InternalPerformance ( ) ,
125
+ performance : new InternalPerformance ( )
118
126
} ;
119
127
120
128
ObjectDefineProperty ( module . exports , 'constants' , {
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const assert = require ( 'assert' ) ;
4
+ const { performance } = require ( 'perf_hooks' ) ;
5
+
6
+ // Test toJSON for performance object
7
+ {
8
+ assert . strictEqual ( typeof performance . toJSON , 'function' ) ;
9
+ const jsonObject = performance . toJSON ( ) ;
10
+ assert . strictEqual ( typeof jsonObject , 'object' ) ;
11
+ assert . strictEqual ( jsonObject . timeOrigin , performance . timeOrigin ) ;
12
+ assert . strictEqual ( typeof jsonObject . nodeTiming , 'object' ) ;
13
+ }
You can’t perform that action at this time.
0 commit comments