Skip to content

Commit

Permalink
Feature flag removal: isGlobalWebPerformanceLoggerEnabled
Browse files Browse the repository at this point in the history
Summary:
## Changelog:
[Internal] -

There is no need for this feature flag anymore, cleaning up.

Reviewed By: rubennorte

Differential Revision: D50925309

fbshipit-source-id: 39ff3d1f85c1df5ba2be287d4b7df2a4222acdba
  • Loading branch information
rshest authored and facebook-github-bot committed Nov 2, 2023
1 parent d5e1eb8 commit 22c4099
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ export type FeatureFlags = {|
* traffic.
*/
animatedShouldUseSingleOp: () => boolean,
/**
* Enables GlobalPerformanceLogger replacement with a WebPerformance API based
* implementation. Tri-state due to being sensitive to initialization order
* vs the platform-specific ReactNativeFeatureFlags implementation.
*/
isGlobalWebPerformanceLoggerEnabled: () => ?boolean,
/**
* Enables access to the host tree in Fabric using DOM-compatible APIs.
*/
Expand All @@ -62,7 +56,6 @@ const ReactNativeFeatureFlags: FeatureFlags = {
shouldPressibilityUseW3CPointerEventsForHover: () => false,
animatedShouldDebounceQueueFlush: () => false,
animatedShouldUseSingleOp: () => false,
isGlobalWebPerformanceLoggerEnabled: () => undefined,
enableAccessToHostTreeInFabric: () => false,
shouldUseAnimatedObjectForTransform: () => false,
shouldUseSetNativePropsInFabric: () => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import createPerformanceLogger from './createPerformanceLogger';
* that are logged during loading bundle. If you want to log something from your
* React component you should use PerformanceLoggerContext instead.
*/
const GlobalPerformanceLogger: IPerformanceLogger =
createPerformanceLogger(true);
const GlobalPerformanceLogger: IPerformanceLogger = createPerformanceLogger();

module.exports = GlobalPerformanceLogger;
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import type {
} from './IPerformanceLogger';

import * as Systrace from '../Performance/Systrace';
import ReactNativeFeatureFlags from '../ReactNative/ReactNativeFeatureFlags';
import NativePerformance from '../WebPerformance/NativePerformance';
import infoLog from './infoLog';

const _cookies: {[key: string]: number, ...} = {};
Expand All @@ -26,7 +24,7 @@ const PRINT_TO_CONSOLE: false = false; // Type as false to prevent accidentally

// This is the prefix for optional logging points/timespans as marks/measures via Performance API,
// used to separate these internally from other marks/measures
const WEB_PERFORMANCE_PREFIX = 'global_perf_';
const WEB_PERFORMANCE_PREFIX = 'web_perf_';

export const getCurrentTimestamp: () => number =
global.nativeQPLTimestamp ?? (() => global.performance.now());
Expand All @@ -37,22 +35,12 @@ class PerformanceLogger implements IPerformanceLogger {
_points: {[key: string]: ?number} = {};
_pointExtras: {[key: string]: ?Extras, ...} = {};
_closed: boolean = false;
_isGlobalLogger: boolean = false;
_isGlobalWebPerformanceLoggerEnabled: ?boolean;
_isLoggingForWebPerformance: boolean = false;

constructor(isGlobalLogger?: boolean) {
this._isGlobalLogger = isGlobalLogger === true;
}

_isLoggingForWebPerformance(): boolean {
if (!this._isGlobalLogger || NativePerformance == null) {
return false;
}
if (this._isGlobalWebPerformanceLoggerEnabled == null) {
this._isGlobalWebPerformanceLoggerEnabled =
ReactNativeFeatureFlags.isGlobalWebPerformanceLoggerEnabled();
}
return this._isGlobalWebPerformanceLoggerEnabled === true;
// When `isLoggingForWebPerformance` is true, the data will be additionally logged via
// Performance.mark/measure API, if available.
constructor(isLoggingForWebPerformance?: boolean) {
this._isLoggingForWebPerformance = isLoggingForWebPerformance === true;
}

// NOTE: The Performance.mark/measure calls are wrapped here to ensure that
Expand All @@ -63,7 +51,7 @@ class PerformanceLogger implements IPerformanceLogger {
// In most of the other cases this kind of check for `performance` being defined
// wouldn't be necessary.
_performanceMark(key: string, startTime: number) {
if (this._isLoggingForWebPerformance()) {
if (this._isLoggingForWebPerformance) {
global.performance?.mark?.(key, {
startTime,
});
Expand All @@ -75,7 +63,7 @@ class PerformanceLogger implements IPerformanceLogger {
start: number | string,
end: number | string,
) {
if (this._isLoggingForWebPerformance()) {
if (this._isLoggingForWebPerformance) {
global.performance?.measure?.(key, {
start,
end,
Expand Down Expand Up @@ -365,7 +353,7 @@ export type {Extras, ExtraValue, IPerformanceLogger, Timespan};
* The loggers need to have minimal overhead since they're used in production.
*/
export default function createPerformanceLogger(
isGlobalLogger?: boolean,
isLoggingForWebPerformance?: boolean,
): IPerformanceLogger {
return new PerformanceLogger(isGlobalLogger);
return new PerformanceLogger(isLoggingForWebPerformance);
}

0 comments on commit 22c4099

Please sign in to comment.