Skip to content

Commit 53a2742

Browse files
rshestfacebook-github-bot
authored andcommitted
Remove web performance logging from GlobalPerformanceLogger (#41299)
Summary: Pull Request resolved: #41299 ## Changelog: It makes sense to keep Web Performance logging mechanism separate from the GlobalPerformanceLogger, removing. Reviewed By: rubennorte Differential Revision: D50930312 fbshipit-source-id: 3b76ff28eae8c5a2bf41faceb33cf188d8318610
1 parent fcda37f commit 53a2742

File tree

1 file changed

+2
-62
lines changed

1 file changed

+2
-62
lines changed

packages/react-native/Libraries/Utilities/createPerformanceLogger.js

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ const _cookies: {[key: string]: number, ...} = {};
2222

2323
const PRINT_TO_CONSOLE: false = false; // Type as false to prevent accidentally committing `true`;
2424

25-
// This is the prefix for optional logging points/timespans as marks/measures via Performance API,
26-
// used to separate these internally from other marks/measures
27-
const WEB_PERFORMANCE_PREFIX = 'web_perf_';
28-
2925
export const getCurrentTimestamp: () => number =
3026
global.nativeQPLTimestamp ?? (() => global.performance.now());
3127

@@ -35,41 +31,6 @@ class PerformanceLogger implements IPerformanceLogger {
3531
_points: {[key: string]: ?number} = {};
3632
_pointExtras: {[key: string]: ?Extras, ...} = {};
3733
_closed: boolean = false;
38-
_isLoggingForWebPerformance: boolean = false;
39-
40-
// When `isLoggingForWebPerformance` is true, the data will be additionally logged via
41-
// Performance.mark/measure API, if available.
42-
constructor(isLoggingForWebPerformance?: boolean) {
43-
this._isLoggingForWebPerformance = isLoggingForWebPerformance === true;
44-
}
45-
46-
// NOTE: The Performance.mark/measure calls are wrapped here to ensure that
47-
// we are safe from the cases when the global 'peformance' object is still not yet defined.
48-
// It is only necessary in this file because of potential race conditions in the initialization
49-
// order between 'createPerformanceLogger' and 'setUpPerformance'.
50-
//
51-
// In most of the other cases this kind of check for `performance` being defined
52-
// wouldn't be necessary.
53-
_performanceMark(key: string, startTime: number) {
54-
if (this._isLoggingForWebPerformance) {
55-
global.performance?.mark?.(key, {
56-
startTime,
57-
});
58-
}
59-
}
60-
61-
_performanceMeasure(
62-
key: string,
63-
start: number | string,
64-
end: number | string,
65-
) {
66-
if (this._isLoggingForWebPerformance) {
67-
global.performance?.measure?.(key, {
68-
start,
69-
end,
70-
});
71-
}
72-
}
7334

7435
addTimespan(
7536
key: string,
@@ -101,12 +62,6 @@ class PerformanceLogger implements IPerformanceLogger {
10162
startExtras,
10263
endExtras,
10364
};
104-
105-
this._performanceMeasure(
106-
`${WEB_PERFORMANCE_PREFIX}_${key}`,
107-
startTime,
108-
endTime,
109-
);
11065
}
11166

11267
append(performanceLogger: IPerformanceLogger) {
@@ -221,8 +176,6 @@ class PerformanceLogger implements IPerformanceLogger {
221176
if (extras) {
222177
this._pointExtras[key] = extras;
223178
}
224-
225-
this._performanceMark(`${WEB_PERFORMANCE_PREFIX}_${key}`, timestamp);
226179
}
227180

228181
removeExtra(key: string): ?ExtraValue {
@@ -284,11 +237,6 @@ class PerformanceLogger implements IPerformanceLogger {
284237
if (PRINT_TO_CONSOLE) {
285238
infoLog('PerformanceLogger.js', 'start: ' + key);
286239
}
287-
288-
this._performanceMark(
289-
`${WEB_PERFORMANCE_PREFIX}_timespan_start_${key}`,
290-
timestamp,
291-
);
292240
}
293241

294242
stopTimespan(
@@ -334,12 +282,6 @@ class PerformanceLogger implements IPerformanceLogger {
334282
Systrace.endAsyncEvent(key, _cookies[key]);
335283
delete _cookies[key];
336284
}
337-
338-
this._performanceMeasure(
339-
`${WEB_PERFORMANCE_PREFIX}_${key}`,
340-
`${WEB_PERFORMANCE_PREFIX}_timespan_start_${key}`,
341-
timestamp,
342-
);
343285
}
344286
}
345287

@@ -352,8 +294,6 @@ export type {Extras, ExtraValue, IPerformanceLogger, Timespan};
352294
* various performance data such as timespans, points and extras.
353295
* The loggers need to have minimal overhead since they're used in production.
354296
*/
355-
export default function createPerformanceLogger(
356-
isLoggingForWebPerformance?: boolean,
357-
): IPerformanceLogger {
358-
return new PerformanceLogger(isLoggingForWebPerformance);
297+
export default function createPerformanceLogger(): IPerformanceLogger {
298+
return new PerformanceLogger();
359299
}

0 commit comments

Comments
 (0)