MCPcopy Index your code
hub / github.com/react/react / ProfilerStore

Class ProfilerStore

packages/react-devtools-shared/src/devtools/ProfilerStore.js:25–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23} from './views/Profiler/types';
24
25export default class ProfilerStore extends EventEmitter<{
26 isProcessingData: [],
27 isProfiling: [],
28 profilingData: [],
29}> {
30 _bridge: FrontendBridge;
31
32 // Suspense cache for lazily calculating derived profiling data.
33 _cache: ProfilingCache;
34
35 // Temporary store of profiling data from the backend renderer(s).
36 // This data will be converted to the ProfilingDataFrontend format after being collected from all renderers.
37 _dataBackends: Array<ProfilingDataBackend> = [];
38
39 // Data from the most recently completed profiling session,
40 // or data that has been imported from a previously exported session.
41 // This object contains all necessary data to drive the Profiler UI interface,
42 // even though some of it is lazily parsed/derived via the ProfilingCache.
43 _dataFrontend: ProfilingDataFrontend | null = null;
44
45 // Snapshot of all attached renderer IDs.
46 // Once profiling is finished, this snapshot will be used to query renderers for profiling data.
47 //
48 // This map is initialized when profiling starts and updated when a new root is added while profiling;
49 // Upon completion, it is converted into the exportable ProfilingDataFrontend format.
50 _initialRendererIDs: Set<number> = new Set();
51
52 // Snapshot of the state of the main Store (including all roots) when profiling started.
53 // Once profiling is finished, this snapshot can be used along with "operations" messages emitted during profiling,
54 // to reconstruct the state of each root for each commit.
55 // It's okay to use a single root to store this information because node IDs are unique across all roots.
56 //
57 // This map is initialized when profiling starts and updated when a new root is added while profiling;
58 // Upon completion, it is converted into the exportable ProfilingDataFrontend format.
59 _initialSnapshotsByRootID: Map<number, Map<number, SnapshotNode>> = new Map();
60
61 // Map of root (id) to a list of tree mutation that occur during profiling.
62 // Once profiling is finished, these mutations can be used, along with the initial tree snapshots,
63 // to reconstruct the state of each root for each commit.
64 //
65 // This map is only updated while profiling is in progress;
66 // Upon completion, it is converted into the exportable ProfilingDataFrontend format.
67 _inProgressOperationsByRootID: Map<number, Array<Array<number>>> = new Map();
68
69 // The backend is currently profiling.
70 // When profiling is in progress, operations are stored so that we can later reconstruct past commit trees.
71 _isBackendProfiling: boolean = false;
72
73 // Mainly used for optimistic UI.
74 // This could be false, but at the same time _isBackendProfiling could be true
75 // for cases when Backend is busy serializing a chunky payload.
76 _isProfilingBasedOnUserInput: boolean = false;
77
78 // Tracks whether a specific renderer logged any profiling data during the most recent session.
79 _rendererIDsThatReportedProfilingData: Set<number> = new Set();
80
81 // After profiling, data is requested from each attached renderer using this queue.
82 // So long as this queue is not empty, the store is retrieving and processing profiling data from the backend.

Callers

nothing calls this directly

Calls 15

logEventFunction · 0.90
getElementByIDMethod · 0.80
setMethod · 0.80
addMethod · 0.80
invalidateMethod · 0.80
forEachMethod · 0.65
getMethod · 0.65
pushMethod · 0.65
hasMethod · 0.65
removeListenerMethod · 0.65
valuesMethod · 0.65

Tested by

no test coverage detected