ProfilerStore Class — react Architecture
Architecture documentation for the ProfilerStore class in ProfilerStore.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 3fc29544_4278_4ce9_4b80_afb09671b539["ProfilerStore"] 85373914_42ee_ed07_c5b1_5dac4e356a82["ProfilerStore.js"] 3fc29544_4278_4ce9_4b80_afb09671b539 -->|defined in| 85373914_42ee_ed07_c5b1_5dac4e356a82 ec4c1b74_c8d1_a615_58d8_99ffb6e7ecc3["if()"] 3fc29544_4278_4ce9_4b80_afb09671b539 -->|method| ec4c1b74_c8d1_a615_58d8_99ffb6e7ecc3
Relationship Graph
Source Code
packages/react-devtools-shared/src/devtools/ProfilerStore.js lines 25–125
export default class ProfilerStore extends EventEmitter<{
isProcessingData: [],
isProfiling: [],
profilingData: [],
}> {
_bridge: FrontendBridge;
// Suspense cache for lazily calculating derived profiling data.
_cache: ProfilingCache;
// Temporary store of profiling data from the backend renderer(s).
// This data will be converted to the ProfilingDataFrontend format after being collected from all renderers.
_dataBackends: Array<ProfilingDataBackend> = [];
// Data from the most recently completed profiling session,
// or data that has been imported from a previously exported session.
// This object contains all necessary data to drive the Profiler UI interface,
// even though some of it is lazily parsed/derived via the ProfilingCache.
_dataFrontend: ProfilingDataFrontend | null = null;
// Snapshot of all attached renderer IDs.
// Once profiling is finished, this snapshot will be used to query renderers for profiling data.
//
// This map is initialized when profiling starts and updated when a new root is added while profiling;
// Upon completion, it is converted into the exportable ProfilingDataFrontend format.
_initialRendererIDs: Set<number> = new Set();
// Snapshot of the state of the main Store (including all roots) when profiling started.
// Once profiling is finished, this snapshot can be used along with "operations" messages emitted during profiling,
// to reconstruct the state of each root for each commit.
// It's okay to use a single root to store this information because node IDs are unique across all roots.
//
// This map is initialized when profiling starts and updated when a new root is added while profiling;
// Upon completion, it is converted into the exportable ProfilingDataFrontend format.
_initialSnapshotsByRootID: Map<number, Map<number, SnapshotNode>> = new Map();
// Map of root (id) to a list of tree mutation that occur during profiling.
// Once profiling is finished, these mutations can be used, along with the initial tree snapshots,
// to reconstruct the state of each root for each commit.
//
// This map is only updated while profiling is in progress;
// Upon completion, it is converted into the exportable ProfilingDataFrontend format.
_inProgressOperationsByRootID: Map<number, Array<Array<number>>> = new Map();
// The backend is currently profiling.
// When profiling is in progress, operations are stored so that we can later reconstruct past commit trees.
_isBackendProfiling: boolean = false;
// Mainly used for optimistic UI.
// This could be false, but at the same time _isBackendProfiling could be true
// for cases when Backend is busy serializing a chunky payload.
_isProfilingBasedOnUserInput: boolean = false;
// Tracks whether a specific renderer logged any profiling data during the most recent session.
_rendererIDsThatReportedProfilingData: Set<number> = new Set();
// After profiling, data is requested from each attached renderer using this queue.
// So long as this queue is not empty, the store is retrieving and processing profiling data from the backend.
_rendererQueue: Set<number> = new Set();
_store: Store;
constructor(
bridge: FrontendBridge,
store: Store,
defaultIsProfiling: boolean,
) {
super();
this._bridge = bridge;
this._isBackendProfiling = defaultIsProfiling;
this._isProfilingBasedOnUserInput = defaultIsProfiling;
this._store = store;
bridge.addListener('operations', this.onBridgeOperations);
bridge.addListener('profilingData', this.onBridgeProfilingData);
bridge.addListener('profilingStatus', this.onProfilingStatus);
bridge.addListener('shutdown', this.onBridgeShutdown);
// It's possible that profiling has already started (e.g. "reload and start profiling")
// so the frontend needs to ask the backend for its status after mounting.
Domain
Source
Frequently Asked Questions
What is the ProfilerStore class?
ProfilerStore is a class in the react codebase, defined in packages/react-devtools-shared/src/devtools/ProfilerStore.js.
Where is ProfilerStore defined?
ProfilerStore is defined in packages/react-devtools-shared/src/devtools/ProfilerStore.js at line 25.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free