Skip to content

Commit 0d9a0b5

Browse files
committed
[Perf Tracks]: Clear potentially large measures
1 parent 06fcc8f commit 0d9a0b5

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

packages/react-reconciler/src/ReactFiberPerformanceTrack.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ const reusableComponentOptions: PerformanceMeasureOptions = {
200200
},
201201
};
202202

203-
const resuableChangedPropsEntry = ['Changed Props', ''];
203+
const reusableChangedPropsEntry = ['Changed Props', ''];
204204

205205
const DEEP_EQUALITY_WARNING =
206206
'This component received deeply equal props. It might benefit from useMemo or the React Compiler in its owner.';
@@ -261,7 +261,7 @@ export function logComponentRender(
261261
alternate.memoizedProps !== props
262262
) {
263263
// If this is an update, we'll diff the props and emit which ones changed.
264-
const properties: Array<[string, string]> = [resuableChangedPropsEntry];
264+
const properties: Array<[string, string]> = [reusableChangedPropsEntry];
265265
const isDeeplyEqual = addObjectDiffToProperties(
266266
alternate.memoizedProps,
267267
props,
@@ -293,18 +293,20 @@ export function logComponentRender(
293293
reusableComponentOptions.start = startTime;
294294
reusableComponentOptions.end = endTime;
295295

296+
const measureName = '\u200b' + name;
296297
if (debugTask != null) {
297298
debugTask.run(
298299
// $FlowFixMe[method-unbinding]
299300
performance.measure.bind(
300301
performance,
301-
'\u200b' + name,
302+
measureName,
302303
reusableComponentOptions,
303304
),
304305
);
305306
} else {
306-
performance.measure('\u200b' + name, reusableComponentOptions);
307+
performance.measure(measureName, reusableComponentOptions);
307308
}
309+
performance.clearMeasures(measureName);
308310
}
309311
} else {
310312
if (debugTask != null) {
@@ -397,14 +399,17 @@ export function logComponentErrored(
397399
},
398400
},
399401
};
402+
403+
const measureName = '\u200b' + name;
400404
if (__DEV__ && debugTask) {
401405
debugTask.run(
402406
// $FlowFixMe[method-unbinding]
403-
performance.measure.bind(performance, '\u200b' + name, options),
407+
performance.measure.bind(performance, measureName, options),
404408
);
405409
} else {
406-
performance.measure('\u200b' + name, options);
410+
performance.measure(measureName, options);
407411
}
412+
performance.clearMeasures(measureName);
408413
} else {
409414
console.timeStamp(
410415
name,
@@ -464,14 +469,16 @@ function logComponentEffectErrored(
464469
},
465470
};
466471
const debugTask = fiber._debugTask;
472+
const measureName = '\u200b' + name;
467473
if (debugTask) {
468474
debugTask.run(
469475
// $FlowFixMe[method-unbinding]
470-
performance.measure.bind(performance, '\u200b' + name, options),
476+
performance.measure.bind(performance, measureName, options),
471477
);
472478
} else {
473-
performance.measure('\u200b' + name, options);
479+
performance.measure(measureName, options);
474480
}
481+
performance.clearMeasures(measureName);
475482
} else {
476483
console.timeStamp(
477484
name,

0 commit comments

Comments
 (0)