2
2
3
3
const {
4
4
ObjectDefineProperties,
5
- ObjectSetPrototypeOf,
6
5
SafeMap,
7
6
SafeSet,
8
7
SafeArrayIterator,
9
8
Symbol,
10
9
SymbolToStringTag,
11
- ReflectConstruct,
12
10
} = primordials ;
13
11
14
- const { initPerformanceEntry, PerformanceEntry } = require ( 'internal/perf/performance_entry' ) ;
12
+ const { initPerformanceEntry, PerformanceEntry, kSkipThrow } = require ( 'internal/perf/performance_entry' ) ;
15
13
const { now } = require ( 'internal/perf/utils' ) ;
16
14
const { enqueue, bufferUserTiming } = require ( 'internal/perf/observe' ) ;
17
15
const nodeTiming = require ( 'internal/perf/nodetiming' ) ;
@@ -69,7 +67,7 @@ function getMark(name) {
69
67
return ts ;
70
68
}
71
69
72
- class PerformanceMark {
70
+ class PerformanceMark extends PerformanceEntry {
73
71
constructor ( name , options = kEmptyObject ) {
74
72
if ( arguments . length === 0 ) {
75
73
throw new ERR_MISSING_ARGS ( 'name' ) ;
@@ -89,6 +87,7 @@ class PerformanceMark {
89
87
detail = detail != null ?
90
88
structuredClone ( detail ) :
91
89
null ;
90
+ super ( kSkipThrow ) ;
92
91
initPerformanceEntry ( this , name , 'mark' , startTime , 0 ) ;
93
92
this [ kDetail ] = detail ;
94
93
}
@@ -108,8 +107,7 @@ class PerformanceMark {
108
107
} ;
109
108
}
110
109
}
111
- ObjectSetPrototypeOf ( PerformanceMark , PerformanceEntry ) ;
112
- ObjectSetPrototypeOf ( PerformanceMark . prototype , PerformanceEntry . prototype ) ;
110
+
113
111
ObjectDefineProperties ( PerformanceMark . prototype , {
114
112
detail : kEnumerableProperty ,
115
113
[ SymbolToStringTag ] : {
@@ -120,8 +118,19 @@ ObjectDefineProperties(PerformanceMark.prototype, {
120
118
} ) ;
121
119
122
120
class PerformanceMeasure extends PerformanceEntry {
123
- constructor ( ) {
124
- throw new ERR_ILLEGAL_CONSTRUCTOR ( ) ;
121
+ constructor (
122
+ skipThrowSymbol = undefined ,
123
+ name = undefined ,
124
+ type = undefined ,
125
+ start = undefined ,
126
+ duration = undefined ,
127
+ ) {
128
+ if ( skipThrowSymbol !== kSkipThrow ) {
129
+ throw new ERR_ILLEGAL_CONSTRUCTOR ( ) ;
130
+ }
131
+
132
+ super ( skipThrowSymbol ) ;
133
+ initPerformanceEntry ( this , name , type , start , duration ) ;
125
134
}
126
135
127
136
get detail ( ) {
@@ -139,10 +148,11 @@ ObjectDefineProperties(PerformanceMeasure.prototype, {
139
148
} ) ;
140
149
141
150
function createPerformanceMeasure ( name , start , duration , detail ) {
142
- return ReflectConstruct ( function PerformanceMeasure ( ) {
143
- initPerformanceEntry ( this , name , 'measure' , start , duration ) ;
144
- this [ kDetail ] = detail ;
145
- } , [ ] , PerformanceMeasure ) ;
151
+ const measure = new PerformanceMeasure ( kSkipThrow , name , 'measure' , start , duration ) ;
152
+
153
+ measure [ kDetail ] = detail ;
154
+
155
+ return measure ;
146
156
}
147
157
148
158
function mark ( name , options ) {
0 commit comments