@@ -95,38 +95,52 @@ function timeLogImpl(timesStore, implementation, logImp, label, args) {
9595 * @param {SafeMap } timesStore
9696 * @param {string } traceCategory
9797 * @param {string } implementation
98- * @param {string } label
98+ * @param {string } logLabel
9999 * @returns {void }
100100 */
101- function time ( timesStore , traceCategory , implementation , label = 'default' ) {
101+ function time ( timesStore , traceCategory , implementation , logLabel = 'default' , traceLabel = undefined ) {
102102 // Coerces everything other than Symbol to a string
103- label = `${ label } ` ;
104- if ( timesStore . has ( label ) ) {
105- process . emitWarning ( `Label '${ label } ' already exists for ${ implementation } ` ) ;
103+ logLabel = `${ logLabel } ` ;
104+
105+ if ( traceLabel !== undefined ) {
106+ traceLabel = `${ traceLabel } ` ;
107+ } else {
108+ traceLabel = logLabel ;
109+ }
110+
111+ if ( timesStore . has ( logLabel ) ) {
112+ process . emitWarning ( `Label '${ logLabel } ' already exists for ${ implementation } ` ) ;
106113 return ;
107114 }
108115
109- trace ( kTraceBegin , traceCategory , `time:: ${ label } ` , 0 ) ;
110- timesStore . set ( label , process . hrtime ( ) ) ;
116+ trace ( kTraceBegin , traceCategory , traceLabel , 0 ) ;
117+ timesStore . set ( logLabel , process . hrtime ( ) ) ;
111118}
112119
113120/**
114121 * @param {SafeMap } timesStore
115122 * @param {string } traceCategory
116123 * @param {string } implementation
117124 * @param {LogImpl } logImpl
118- * @param {string } label
125+ * @param {string } logLabel
126+ * @param {string } traceLabel
119127 * @returns {void }
120128 */
121- function timeEnd ( timesStore , traceCategory , implementation , logImpl , label = 'default' ) {
129+ function timeEnd ( timesStore , traceCategory , implementation , logImpl , logLabel = 'default' , traceLabel = undefined ) {
122130 // Coerces everything other than Symbol to a string
123- label = `${ label } ` ;
131+ logLabel = `${ logLabel } ` ;
132+
133+ if ( traceLabel !== undefined ) {
134+ traceLabel = `${ traceLabel } ` ;
135+ } else {
136+ traceLabel = logLabel ;
137+ }
124138
125- const found = timeLogImpl ( timesStore , implementation , logImpl , label ) ;
126- trace ( kTraceEnd , traceCategory , `time:: ${ label } ` , 0 ) ;
139+ const found = timeLogImpl ( timesStore , implementation , logImpl , logLabel ) ;
140+ trace ( kTraceEnd , traceCategory , traceLabel , 0 ) ;
127141
128142 if ( found ) {
129- timesStore . delete ( label ) ;
143+ timesStore . delete ( logLabel ) ;
130144 }
131145}
132146
@@ -135,16 +149,24 @@ function timeEnd(timesStore, traceCategory, implementation, logImpl, label = 'de
135149 * @param {string } traceCategory
136150 * @param {string } implementation
137151 * @param {LogImpl } logImpl
138- * @param {string } label
152+ * @param {string } logLabel
153+ * @param {string } traceLabel
139154 * @param {any[] } args
140155 * @returns {void }
141156 */
142- function timeLog ( timesStore , traceCategory , implementation , logImpl , label = 'default' , args ) {
157+ function timeLog ( timesStore , traceCategory , implementation , logImpl , logLabel = 'default' , traceLabel = undefined , args ) {
143158 // Coerces everything other than Symbol to a string
144- label = `${ label } ` ;
145- timeLogImpl ( timesStore , implementation , logImpl , label , args ) ;
159+ logLabel = `${ logLabel } ` ;
160+
161+ if ( traceLabel !== undefined ) {
162+ traceLabel = `${ traceLabel } ` ;
163+ } else {
164+ traceLabel = logLabel ;
165+ }
166+
167+ timeLogImpl ( timesStore , implementation , logImpl , logLabel , args ) ;
146168
147- trace ( kTraceInstant , traceCategory , `time:: ${ label } ` , 0 ) ;
169+ trace ( kTraceInstant , traceCategory , traceLabel , 0 ) ;
148170}
149171
150172module . exports = {
0 commit comments