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 { 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' ) ;
@@ -35,7 +33,6 @@ const {
3533
3634const { structuredClone } = require ( 'internal/structured_clone' ) ;
3735const {
38- kEmptyObject,
3936 lazyDOMException,
4037 kEnumerableProperty,
4138} = require ( 'internal/util' ) ;
@@ -69,27 +66,29 @@ function getMark(name) {
6966 return ts ;
7067}
7168
72- class PerformanceMark {
73- constructor ( name , options = kEmptyObject ) {
69+ class PerformanceMark extends PerformanceEntry {
70+ constructor ( name , options = undefined ) {
7471 if ( arguments . length === 0 ) {
7572 throw new ERR_MISSING_ARGS ( 'name' ) ;
7673 }
7774 name = `${ name } ` ;
78- options ??= kEmptyObject ;
7975 if ( nodeTimingReadOnlyAttributes . has ( name ) )
8076 throw new ERR_INVALID_ARG_VALUE ( 'name' , name ) ;
81- validateObject ( options , 'options' ) ;
82- const startTime = options . startTime ?? now ( ) ;
77+ if ( options != null ) {
78+ validateObject ( options , 'options' ) ;
79+ }
80+ const startTime = options ?. startTime ?? now ( ) ;
8381 validateNumber ( startTime , 'startTime' ) ;
8482 if ( startTime < 0 )
8583 throw new ERR_PERFORMANCE_INVALID_TIMESTAMP ( startTime ) ;
8684 markTimings . set ( name , startTime ) ;
8785
88- let detail = options . detail ;
86+ let detail = options ? .detail ;
8987 detail = detail != null ?
9088 structuredClone ( detail ) :
9189 null ;
92- initPerformanceEntry ( this , name , 'mark' , startTime , 0 ) ;
90+
91+ super ( kSkipThrow , name , 'mark' , startTime , 0 ) ;
9392 this [ kDetail ] = detail ;
9493 }
9594
@@ -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,18 @@ 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 , name , type , start , duration ) ;
125133 }
126134
127135 get detail ( ) {
@@ -139,10 +147,11 @@ ObjectDefineProperties(PerformanceMeasure.prototype, {
139147} ) ;
140148
141149function createPerformanceMeasure ( name , start , duration , detail ) {
142- return ReflectConstruct ( function PerformanceMeasure ( ) {
143- initPerformanceEntry ( this , name , 'measure' , start , duration ) ;
144- this [ kDetail ] = detail ;
145- } , [ ] , PerformanceMeasure ) ;
150+ const measure = new PerformanceMeasure ( kSkipThrow , name , 'measure' , start , duration ) ;
151+
152+ measure [ kDetail ] = detail ;
153+
154+ return measure ;
146155}
147156
148157function mark ( name , options ) {
0 commit comments