22
33const {
44 ObjectDefineProperties,
5- ObjectSetPrototypeOf,
65 SafeMap,
76 SafeSet,
87 SafeArrayIterator,
98 Symbol,
109 SymbolToStringTag,
11- ReflectConstruct,
1210} = primordials ;
1311
14- const { initPerformanceEntry, PerformanceEntry } = require ( 'internal/perf/performance_entry' ) ;
12+ const { initPerformanceEntry, PerformanceEntry, kSkipThrow } = require ( 'internal/perf/performance_entry' ) ;
1513const { now } = require ( 'internal/perf/utils' ) ;
1614const { enqueue, bufferUserTiming } = require ( 'internal/perf/observe' ) ;
1715const nodeTiming = require ( 'internal/perf/nodetiming' ) ;
@@ -69,7 +67,7 @@ function getMark(name) {
6967 return ts ;
7068}
7169
72- class PerformanceMark {
70+ class PerformanceMark extends PerformanceEntry {
7371 constructor ( name , options = kEmptyObject ) {
7472 if ( arguments . length === 0 ) {
7573 throw new ERR_MISSING_ARGS ( 'name' ) ;
@@ -89,6 +87,7 @@ class PerformanceMark {
8987 detail = detail != null ?
9088 structuredClone ( detail ) :
9189 null ;
90+ super ( kSkipThrow ) ;
9291 initPerformanceEntry ( this , name , 'mark' , startTime , 0 ) ;
9392 this [ kDetail ] = detail ;
9493 }
@@ -108,8 +107,7 @@ class PerformanceMark {
108107 } ;
109108 }
110109}
111- ObjectSetPrototypeOf ( PerformanceMark , PerformanceEntry ) ;
112- ObjectSetPrototypeOf ( PerformanceMark . prototype , PerformanceEntry . prototype ) ;
110+
113111ObjectDefineProperties ( PerformanceMark . prototype , {
114112 detail : kEnumerableProperty ,
115113 [ SymbolToStringTag ] : {
@@ -120,8 +118,19 @@ ObjectDefineProperties(PerformanceMark.prototype, {
120118} ) ;
121119
122120class 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 ) ;
125134 }
126135
127136 get detail ( ) {
@@ -139,10 +148,11 @@ ObjectDefineProperties(PerformanceMeasure.prototype, {
139148} ) ;
140149
141150function 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 ;
146156}
147157
148158function mark ( name , options ) {
0 commit comments