mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Enable scheduling profiler flag in react-dom/testing builds (#23142)
This commit is contained in:
@@ -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
@@ -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__;
|
||||
|
||||
Reference in New Issue
Block a user