Enable scheduling profiler flag in react-dom/testing builds (#23142)

This commit is contained in:
Brian Vaughn
2022-01-19 11:20:42 -05:00
committed by GitHub
parent 286b926f65
commit deaa1428a4
5 changed files with 33 additions and 23 deletions
@@ -75,7 +75,7 @@ export function createProfilingHooks({
reactVersion,
}: {|
getDisplayNameForFiber: (fiber: Fiber) => string | null,
getLaneLabelMap?: () => Map<Lane, string>,
getLaneLabelMap?: () => Map<Lane, string> | null,
reactVersion: string,
|}): DevToolsProfilingHooks {
function markMetadata() {
@@ -108,8 +108,10 @@ export function createProfilingHooks({
if (typeof getLaneLabelMap === 'function') {
const map = getLaneLabelMap();
const labels = Array.from(map.values()).join(',');
markAndClear(`--react-lane-labels-${labels}`);
if (map != null) {
const labels = Array.from(map.values()).join(',');
markAndClear(`--react-lane-labels-${labels}`);
}
}
}
+1 -1
View File
@@ -152,7 +152,7 @@ export type ReactRenderer = {
scheduleRefresh?: Function,
// 18.0+
injectProfilingHooks?: (profilingHooks: DevToolsProfilingHooks) => void,
getLaneLabelMap?: () => Map<Lane, string>,
getLaneLabelMap?: () => Map<Lane, string> | null,
...
};
@@ -230,17 +230,21 @@ function injectProfilingHooks(profilingHooks: DevToolsProfilingHooks): void {
injectedProfilingHooks = profilingHooks;
}
function getLaneLabelMap(): Map<Lane, string> {
const map: Map<Lane, string> = new Map();
function getLaneLabelMap(): Map<Lane, string> | null {
if (enableSchedulingProfiler) {
const map: Map<Lane, string> = new Map();
let lane = 1;
for (let index = 0; index < TotalLanes; index++) {
const label = ((getLabelForLane(lane): any): string);
map.set(lane, label);
lane *= 2;
let lane = 1;
for (let index = 0; index < TotalLanes; index++) {
const label = ((getLabelForLane(lane): any): string);
map.set(lane, label);
lane *= 2;
}
return map;
} else {
return null;
}
return map;
}
export function markCommitStarted(lanes: Lanes): void {
@@ -230,17 +230,21 @@ function injectProfilingHooks(profilingHooks: DevToolsProfilingHooks): void {
injectedProfilingHooks = profilingHooks;
}
function getLaneLabelMap(): Map<Lane, string> {
const map: Map<Lane, string> = new Map();
function getLaneLabelMap(): Map<Lane, string> | null {
if (enableSchedulingProfiler) {
const map: Map<Lane, string> = new Map();
let lane = 1;
for (let index = 0; index < TotalLanes; index++) {
const label = ((getLabelForLane(lane): any): string);
map.set(lane, label);
lane *= 2;
let lane = 1;
for (let index = 0; index < TotalLanes; index++) {
const label = ((getLabelForLane(lane): any): string);
map.set(lane, label);
lane *= 2;
}
return map;
} else {
return null;
}
return map;
}
export function markCommitStarted(lanes: Lanes): void {
@@ -12,7 +12,7 @@ import typeof * as ExportsType from './ReactFeatureFlags.testing';
export const debugRenderPhaseSideEffectsForStrictMode = false;
export const enableDebugTracing = false;
export const enableSchedulingProfiler = false;
export const enableSchedulingProfiler = __PROFILE__;
export const warnAboutDeprecatedLifecycles = true;
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
export const enableProfilerTimer = __PROFILE__;