mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Support for ReactFeatureFlags.logTopLevelRenders timing (#8687)
Call `console.time` / `console.timeEnd` for the top level component when `ReactFeatureFlags.logTopLevelRenders` is enabled
This commit is contained in:
1 parent
4f8c16a750
commit
f546505e4e
3 files changed
+18
-3
No files matched your search
@@ -40,6 +40,7 @@ var ReactFiberCompleteWork = require('ReactFiberCompleteWork');
|
||||
var ReactFiberCommitWork = require('ReactFiberCommitWork');
|
||||
var ReactFiberHostContext = require('ReactFiberHostContext');
|
||||
var ReactCurrentOwner = require('ReactCurrentOwner');
|
||||
var ReactFeatureFlags = require('ReactFeatureFlags');
|
||||
var getComponentName = require('getComponentName');
|
||||
|
||||
var { cloneFiber } = require('ReactFiber');
|
||||
@@ -628,6 +629,18 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
|
||||
nextUnitOfWork = findNextUnitOfWork();
|
||||
}
|
||||
|
||||
let hostRootTimeMarker;
|
||||
if (
|
||||
ReactFeatureFlags.logTopLevelRenders &&
|
||||
nextUnitOfWork &&
|
||||
nextUnitOfWork.tag === HostRoot &&
|
||||
nextUnitOfWork.child
|
||||
) {
|
||||
const componentName = getComponentName(nextUnitOfWork.child) || '';
|
||||
hostRootTimeMarker = 'React update: ' + componentName;
|
||||
console.time(hostRootTimeMarker);
|
||||
}
|
||||
|
||||
// If there's a deadline, and we're not performing Task work, perform work
|
||||
// using this loop that checks the deadline on every iteration.
|
||||
if (deadline && priorityLevel > TaskPriority) {
|
||||
@@ -673,6 +686,10 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
|
||||
}
|
||||
}
|
||||
|
||||
if (hostRootTimeMarker) {
|
||||
console.timeEnd(hostRootTimeMarker);
|
||||
}
|
||||
|
||||
return deadlineHasExpired;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user