Skip to content

Commit a236a1a

Browse files
author
Brian Vaughn
committed
Support for ReactFeatureFlags.logTopLevelRenders timing
Initial stab at calling console.time/console.timeEnd for the top level component when ReactFeatureFlags.logTopLevelRenders is enabled
1 parent 4f8c16a commit a236a1a

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

scripts/fiber/tests-failing.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,5 @@ src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
6161
src/renderers/shared/shared/__tests__/ReactMultiChildText-test.js
6262
* should reorder keyed text nodes
6363

64-
src/renderers/shared/shared/__tests__/ReactUpdates-test.js
65-
* marks top-level updates
66-
6764
src/renderers/shared/shared/__tests__/refs-test.js
6865
* Should increase refs with an increase in divs

scripts/fiber/tests-passing.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,6 +1598,7 @@ src/renderers/shared/shared/__tests__/ReactUpdates-test.js
15981598
* should queue updates from during mount
15991599
* calls componentWillReceiveProps setState callback properly
16001600
* does not call render after a component as been deleted
1601+
* marks top-level updates
16011602
* throws in setState if the update callback is not a function
16021603
* throws in replaceState if the update callback is not a function
16031604
* throws in forceUpdate if the update callback is not a function

src/renderers/shared/fiber/ReactFiberScheduler.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var ReactFiberCompleteWork = require('ReactFiberCompleteWork');
4040
var ReactFiberCommitWork = require('ReactFiberCommitWork');
4141
var ReactFiberHostContext = require('ReactFiberHostContext');
4242
var ReactCurrentOwner = require('ReactCurrentOwner');
43+
var ReactFeatureFlags = require('ReactFeatureFlags');
4344
var getComponentName = require('getComponentName');
4445

4546
var { cloneFiber } = require('ReactFiber');
@@ -628,6 +629,18 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
628629
nextUnitOfWork = findNextUnitOfWork();
629630
}
630631

632+
let hostRootTimeMarker;
633+
if (
634+
ReactFeatureFlags.logTopLevelRenders &&
635+
nextUnitOfWork &&
636+
nextUnitOfWork.tag === HostRoot &&
637+
nextUnitOfWork.child
638+
) {
639+
const componentName = getComponentName(nextUnitOfWork.child) || '';
640+
hostRootTimeMarker = 'React update: ' + componentName;
641+
console.time(hostRootTimeMarker);
642+
}
643+
631644
// If there's a deadline, and we're not performing Task work, perform work
632645
// using this loop that checks the deadline on every iteration.
633646
if (deadline && priorityLevel > TaskPriority) {
@@ -673,6 +686,10 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
673686
}
674687
}
675688

689+
if (hostRootTimeMarker) {
690+
console.timeEnd(hostRootTimeMarker);
691+
}
692+
676693
return deadlineHasExpired;
677694
}
678695

0 commit comments

Comments
 (0)