react 15.0.2 → 15.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-with-addons.js +1545 -918
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +1515 -1339
- package/dist/react.min.js +6 -6
- package/lib/CSSPropertyOperations.js +5 -5
- package/lib/DOMChildrenOperations.js +41 -6
- package/lib/DOMLazyTree.js +15 -3
- package/lib/DOMPropertyOperations.js +22 -13
- package/lib/LinkedStateMixin.js +1 -0
- package/lib/ReactCSSTransitionGroup.js +5 -0
- package/lib/ReactChildren.js +9 -1
- package/lib/ReactClass.js +1 -0
- package/lib/ReactComponentBrowserEnvironment.js +0 -5
- package/lib/ReactComponentTreeDevtool.js +145 -0
- package/lib/ReactComponentWithPureRenderMixin.js +2 -0
- package/lib/ReactCompositeComponent.js +147 -18
- package/lib/ReactDOM.js +1 -4
- package/lib/ReactDOMComponent.js +51 -11
- package/lib/ReactDOMIDOperations.js +0 -5
- package/lib/ReactDOMInput.js +5 -3
- package/lib/ReactDOMTextComponent.js +7 -6
- package/lib/ReactDebugTool.js +188 -10
- package/lib/ReactDefaultInjection.js +0 -9
- package/lib/ReactElement.js +26 -0
- package/lib/ReactFragment.js +5 -2
- package/lib/ReactInjection.js +0 -2
- package/lib/ReactLink.js +3 -0
- package/lib/ReactMount.js +22 -7
- package/lib/ReactMultiChild.js +21 -0
- package/lib/ReactNativeAttributePayload.js +7 -36
- package/lib/{IOSNativeBridgeEventPlugin.js → ReactNativeBridgeEventPlugin.js} +8 -5
- package/lib/ReactNativeDOMIDOperations.js +3 -6
- package/lib/ReactNativeDefaultInjection.js +15 -12
- package/lib/ReactNativeEventEmitter.js +6 -3
- package/lib/{IOSDefaultEventPluginOrder.js → ReactNativeEventPluginOrder.js} +3 -3
- package/lib/ReactNativeMount.js +24 -7
- package/lib/ReactNativeOperationHistoryDevtool.js +37 -0
- package/lib/ReactNativeTextComponent.js +8 -0
- package/lib/ReactPerf.js +397 -75
- package/lib/ReactReconciler.js +46 -5
- package/lib/ReactServerRendering.js +20 -1
- package/lib/ReactServerRenderingTransaction.js +5 -1
- package/lib/ReactTestUtils.js +8 -0
- package/lib/ReactTransitionGroup.js +5 -0
- package/lib/ReactUpdates.js +21 -3
- package/lib/ReactVersion.js +1 -1
- package/lib/ReactWithAddons.js +1 -1
- package/lib/findDOMNode.js +2 -0
- package/lib/instantiateReactComponent.js +34 -1
- package/lib/onlyChild.js +7 -4
- package/lib/shallowCompare.js +1 -0
- package/lib/update.js +4 -0
- package/package.json +2 -2
- package/lib/ReactDebugInstanceMap.js +0 -102
- package/lib/ReactDefaultPerf.js +0 -316
- package/lib/ReactDefaultPerfAnalysis.js +0 -210
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule ReactNativeOperationHistoryDevtool
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var history = [];
|
|
15
|
+
|
|
16
|
+
var ReactNativeOperationHistoryDevtool = {
|
|
17
|
+
onNativeOperation: function (debugID, type, payload) {
|
|
18
|
+
history.push({
|
|
19
|
+
instanceID: debugID,
|
|
20
|
+
type: type,
|
|
21
|
+
payload: payload
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
clearHistory: function () {
|
|
25
|
+
if (ReactNativeOperationHistoryDevtool._preventClearing) {
|
|
26
|
+
// Should only be used for tests.
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
history = [];
|
|
31
|
+
},
|
|
32
|
+
getHistory: function () {
|
|
33
|
+
return history;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
module.exports = ReactNativeOperationHistoryDevtool;
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
var _assign = require('object-assign');
|
|
15
15
|
|
|
16
|
+
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
16
17
|
var ReactNativeComponentTree = require('./ReactNativeComponentTree');
|
|
17
18
|
var ReactNativeTagHandles = require('./ReactNativeTagHandles');
|
|
18
19
|
var UIManager = require('UIManager');
|
|
@@ -30,6 +31,10 @@ var ReactNativeTextComponent = function (text) {
|
|
|
30
31
|
_assign(ReactNativeTextComponent.prototype, {
|
|
31
32
|
|
|
32
33
|
mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
|
|
34
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
35
|
+
ReactInstrumentation.debugTool.onSetText(this._debugID, this._stringText);
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
// TODO: nativeParent should have this context already. Stop abusing context.
|
|
34
39
|
!context.isInAParentText ? process.env.NODE_ENV !== 'production' ? invariant(false, 'RawText "%s" must be wrapped in an explicit <Text> component.', this._stringText) : invariant(false) : void 0;
|
|
35
40
|
this._nativeParent = nativeParent;
|
|
@@ -54,6 +59,9 @@ _assign(ReactNativeTextComponent.prototype, {
|
|
|
54
59
|
if (nextStringText !== this._stringText) {
|
|
55
60
|
this._stringText = nextStringText;
|
|
56
61
|
UIManager.updateView(this._rootNodeID, 'RCTRawText', { text: this._stringText });
|
|
62
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
63
|
+
ReactInstrumentation.debugTool.onSetText(this._debugID, nextStringText);
|
|
64
|
+
}
|
|
57
65
|
}
|
|
58
66
|
}
|
|
59
67
|
},
|
package/lib/ReactPerf.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2016-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -11,86 +11,408 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
* ReactPerf is a general AOP system designed to measure performance. This
|
|
16
|
-
* module only has the hooks: see ReactDefaultPerf for the analysis tool.
|
|
17
|
-
*/
|
|
14
|
+
var _assign = require('object-assign');
|
|
18
15
|
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
16
|
+
var _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
17
|
+
|
|
18
|
+
var ReactDebugTool = require('./ReactDebugTool');
|
|
19
|
+
var warning = require('fbjs/lib/warning');
|
|
20
|
+
|
|
21
|
+
function roundFloat(val) {
|
|
22
|
+
var base = arguments.length <= 1 || arguments[1] === undefined ? 2 : arguments[1];
|
|
23
|
+
|
|
24
|
+
var n = Math.pow(10, base);
|
|
25
|
+
return Math.floor(val * n) / n;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getFlushHistory() {
|
|
29
|
+
return ReactDebugTool.getFlushHistory();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getExclusive() {
|
|
33
|
+
var flushHistory = arguments.length <= 0 || arguments[0] === undefined ? getFlushHistory() : arguments[0];
|
|
34
|
+
|
|
35
|
+
var aggregatedStats = {};
|
|
36
|
+
var affectedIDs = {};
|
|
37
|
+
|
|
38
|
+
function updateAggregatedStats(treeSnapshot, instanceID, timerType, applyUpdate) {
|
|
39
|
+
var displayName = treeSnapshot[instanceID].displayName;
|
|
40
|
+
|
|
41
|
+
var key = displayName;
|
|
42
|
+
var stats = aggregatedStats[key];
|
|
43
|
+
if (!stats) {
|
|
44
|
+
affectedIDs[key] = {};
|
|
45
|
+
stats = aggregatedStats[key] = {
|
|
46
|
+
key: key,
|
|
47
|
+
instanceCount: 0,
|
|
48
|
+
counts: {},
|
|
49
|
+
durations: {},
|
|
50
|
+
totalDuration: 0
|
|
51
|
+
};
|
|
45
52
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
if (!stats.durations[timerType]) {
|
|
54
|
+
stats.durations[timerType] = 0;
|
|
55
|
+
}
|
|
56
|
+
if (!stats.counts[timerType]) {
|
|
57
|
+
stats.counts[timerType] = 0;
|
|
58
|
+
}
|
|
59
|
+
affectedIDs[key][instanceID] = true;
|
|
60
|
+
applyUpdate(stats);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
flushHistory.forEach(function (flush) {
|
|
64
|
+
var measurements = flush.measurements;
|
|
65
|
+
var treeSnapshot = flush.treeSnapshot;
|
|
66
|
+
|
|
67
|
+
measurements.forEach(function (measurement) {
|
|
68
|
+
var duration = measurement.duration;
|
|
69
|
+
var instanceID = measurement.instanceID;
|
|
70
|
+
var timerType = measurement.timerType;
|
|
71
|
+
|
|
72
|
+
updateAggregatedStats(treeSnapshot, instanceID, timerType, function (stats) {
|
|
73
|
+
stats.totalDuration += duration;
|
|
74
|
+
stats.durations[timerType] += duration;
|
|
75
|
+
stats.counts[timerType]++;
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return Object.keys(aggregatedStats).map(function (key) {
|
|
81
|
+
return _extends({}, aggregatedStats[key], {
|
|
82
|
+
instanceCount: Object.keys(affectedIDs[key]).length
|
|
83
|
+
});
|
|
84
|
+
}).sort(function (a, b) {
|
|
85
|
+
return b.totalDuration - a.totalDuration;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function getInclusive() {
|
|
90
|
+
var flushHistory = arguments.length <= 0 || arguments[0] === undefined ? getFlushHistory() : arguments[0];
|
|
91
|
+
|
|
92
|
+
var aggregatedStats = {};
|
|
93
|
+
var affectedIDs = {};
|
|
94
|
+
|
|
95
|
+
function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {
|
|
96
|
+
var _treeSnapshot$instanc = treeSnapshot[instanceID];
|
|
97
|
+
var displayName = _treeSnapshot$instanc.displayName;
|
|
98
|
+
var ownerID = _treeSnapshot$instanc.ownerID;
|
|
99
|
+
|
|
100
|
+
var owner = treeSnapshot[ownerID];
|
|
101
|
+
var key = (owner ? owner.displayName + ' > ' : '') + displayName;
|
|
102
|
+
var stats = aggregatedStats[key];
|
|
103
|
+
if (!stats) {
|
|
104
|
+
affectedIDs[key] = {};
|
|
105
|
+
stats = aggregatedStats[key] = {
|
|
106
|
+
key: key,
|
|
107
|
+
instanceCount: 0,
|
|
108
|
+
inclusiveRenderDuration: 0,
|
|
109
|
+
renderCount: 0
|
|
67
110
|
};
|
|
68
|
-
wrapper.displayName = objName + '_' + fnName;
|
|
69
|
-
return wrapper;
|
|
70
111
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
112
|
+
affectedIDs[key][instanceID] = true;
|
|
113
|
+
applyUpdate(stats);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
var isCompositeByID = {};
|
|
117
|
+
flushHistory.forEach(function (flush) {
|
|
118
|
+
var measurements = flush.measurements;
|
|
119
|
+
|
|
120
|
+
measurements.forEach(function (measurement) {
|
|
121
|
+
var instanceID = measurement.instanceID;
|
|
122
|
+
var timerType = measurement.timerType;
|
|
123
|
+
|
|
124
|
+
if (timerType !== 'render') {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
isCompositeByID[instanceID] = true;
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
flushHistory.forEach(function (flush) {
|
|
132
|
+
var measurements = flush.measurements;
|
|
133
|
+
var treeSnapshot = flush.treeSnapshot;
|
|
134
|
+
|
|
135
|
+
measurements.forEach(function (measurement) {
|
|
136
|
+
var duration = measurement.duration;
|
|
137
|
+
var instanceID = measurement.instanceID;
|
|
138
|
+
var timerType = measurement.timerType;
|
|
139
|
+
|
|
140
|
+
if (timerType !== 'render') {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
updateAggregatedStats(treeSnapshot, instanceID, function (stats) {
|
|
144
|
+
stats.renderCount++;
|
|
145
|
+
});
|
|
146
|
+
var nextParentID = instanceID;
|
|
147
|
+
while (nextParentID) {
|
|
148
|
+
// As we traverse parents, only count inclusive time towards composites.
|
|
149
|
+
// We know something is a composite if its render() was called.
|
|
150
|
+
if (isCompositeByID[nextParentID]) {
|
|
151
|
+
updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {
|
|
152
|
+
stats.inclusiveRenderDuration += duration;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
nextParentID = treeSnapshot[nextParentID].parentID;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return Object.keys(aggregatedStats).map(function (key) {
|
|
161
|
+
return _extends({}, aggregatedStats[key], {
|
|
162
|
+
instanceCount: Object.keys(affectedIDs[key]).length
|
|
163
|
+
});
|
|
164
|
+
}).sort(function (a, b) {
|
|
165
|
+
return b.inclusiveRenderDuration - a.inclusiveRenderDuration;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function getWasted() {
|
|
170
|
+
var flushHistory = arguments.length <= 0 || arguments[0] === undefined ? getFlushHistory() : arguments[0];
|
|
171
|
+
|
|
172
|
+
var aggregatedStats = {};
|
|
173
|
+
var affectedIDs = {};
|
|
174
|
+
|
|
175
|
+
function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {
|
|
176
|
+
var _treeSnapshot$instanc2 = treeSnapshot[instanceID];
|
|
177
|
+
var displayName = _treeSnapshot$instanc2.displayName;
|
|
178
|
+
var ownerID = _treeSnapshot$instanc2.ownerID;
|
|
179
|
+
|
|
180
|
+
var owner = treeSnapshot[ownerID];
|
|
181
|
+
var key = (owner ? owner.displayName + ' > ' : '') + displayName;
|
|
182
|
+
var stats = aggregatedStats[key];
|
|
183
|
+
if (!stats) {
|
|
184
|
+
affectedIDs[key] = {};
|
|
185
|
+
stats = aggregatedStats[key] = {
|
|
186
|
+
key: key,
|
|
187
|
+
instanceCount: 0,
|
|
188
|
+
inclusiveRenderDuration: 0,
|
|
189
|
+
renderCount: 0
|
|
190
|
+
};
|
|
80
191
|
}
|
|
192
|
+
affectedIDs[key][instanceID] = true;
|
|
193
|
+
applyUpdate(stats);
|
|
81
194
|
}
|
|
82
|
-
};
|
|
83
195
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
196
|
+
flushHistory.forEach(function (flush) {
|
|
197
|
+
var measurements = flush.measurements;
|
|
198
|
+
var treeSnapshot = flush.treeSnapshot;
|
|
199
|
+
var operations = flush.operations;
|
|
200
|
+
|
|
201
|
+
var isDefinitelyNotWastedByID = {};
|
|
202
|
+
|
|
203
|
+
// Find native components associated with an operation in this batch.
|
|
204
|
+
// Mark all components in their parent tree as definitely not wasted.
|
|
205
|
+
operations.forEach(function (operation) {
|
|
206
|
+
var instanceID = operation.instanceID;
|
|
207
|
+
|
|
208
|
+
var nextParentID = instanceID;
|
|
209
|
+
while (nextParentID) {
|
|
210
|
+
isDefinitelyNotWastedByID[nextParentID] = true;
|
|
211
|
+
nextParentID = treeSnapshot[nextParentID].parentID;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// Find composite components that rendered in this batch.
|
|
216
|
+
// These are potential candidates for being wasted renders.
|
|
217
|
+
var renderedCompositeIDs = {};
|
|
218
|
+
measurements.forEach(function (measurement) {
|
|
219
|
+
var instanceID = measurement.instanceID;
|
|
220
|
+
var timerType = measurement.timerType;
|
|
221
|
+
|
|
222
|
+
if (timerType !== 'render') {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
renderedCompositeIDs[instanceID] = true;
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
measurements.forEach(function (measurement) {
|
|
229
|
+
var duration = measurement.duration;
|
|
230
|
+
var instanceID = measurement.instanceID;
|
|
231
|
+
var timerType = measurement.timerType;
|
|
232
|
+
|
|
233
|
+
if (timerType !== 'render') {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// If there was a DOM update below this component, or it has just been
|
|
238
|
+
// mounted, its render() is not considered wasted.
|
|
239
|
+
var updateCount = treeSnapshot[instanceID].updateCount;
|
|
240
|
+
|
|
241
|
+
if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// We consider this render() wasted.
|
|
246
|
+
updateAggregatedStats(treeSnapshot, instanceID, function (stats) {
|
|
247
|
+
stats.renderCount++;
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
var nextParentID = instanceID;
|
|
251
|
+
while (nextParentID) {
|
|
252
|
+
// Any parents rendered during this batch are considered wasted
|
|
253
|
+
// unless we previously marked them as dirty.
|
|
254
|
+
var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];
|
|
255
|
+
if (isWasted) {
|
|
256
|
+
updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {
|
|
257
|
+
stats.inclusiveRenderDuration += duration;
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
nextParentID = treeSnapshot[nextParentID].parentID;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
return Object.keys(aggregatedStats).map(function (key) {
|
|
266
|
+
return _extends({}, aggregatedStats[key], {
|
|
267
|
+
instanceCount: Object.keys(affectedIDs[key]).length
|
|
268
|
+
});
|
|
269
|
+
}).sort(function (a, b) {
|
|
270
|
+
return b.inclusiveRenderDuration - a.inclusiveRenderDuration;
|
|
271
|
+
});
|
|
94
272
|
}
|
|
95
273
|
|
|
96
|
-
|
|
274
|
+
function getOperations() {
|
|
275
|
+
var flushHistory = arguments.length <= 0 || arguments[0] === undefined ? getFlushHistory() : arguments[0];
|
|
276
|
+
|
|
277
|
+
var stats = [];
|
|
278
|
+
flushHistory.forEach(function (flush, flushIndex) {
|
|
279
|
+
var operations = flush.operations;
|
|
280
|
+
var treeSnapshot = flush.treeSnapshot;
|
|
281
|
+
|
|
282
|
+
operations.forEach(function (operation) {
|
|
283
|
+
var instanceID = operation.instanceID;
|
|
284
|
+
var type = operation.type;
|
|
285
|
+
var payload = operation.payload;
|
|
286
|
+
var _treeSnapshot$instanc3 = treeSnapshot[instanceID];
|
|
287
|
+
var displayName = _treeSnapshot$instanc3.displayName;
|
|
288
|
+
var ownerID = _treeSnapshot$instanc3.ownerID;
|
|
289
|
+
|
|
290
|
+
var owner = treeSnapshot[ownerID];
|
|
291
|
+
var key = (owner ? owner.displayName + ' > ' : '') + displayName;
|
|
292
|
+
|
|
293
|
+
stats.push({
|
|
294
|
+
flushIndex: flushIndex,
|
|
295
|
+
instanceID: instanceID,
|
|
296
|
+
key: key,
|
|
297
|
+
type: type,
|
|
298
|
+
ownerID: ownerID,
|
|
299
|
+
payload: payload
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
return stats;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function printExclusive(flushHistory) {
|
|
307
|
+
var stats = getExclusive(flushHistory);
|
|
308
|
+
var table = stats.map(function (item) {
|
|
309
|
+
var key = item.key;
|
|
310
|
+
var instanceCount = item.instanceCount;
|
|
311
|
+
var totalDuration = item.totalDuration;
|
|
312
|
+
|
|
313
|
+
var renderCount = item.counts.render || 0;
|
|
314
|
+
var renderDuration = item.durations.render || 0;
|
|
315
|
+
return {
|
|
316
|
+
'Component': key,
|
|
317
|
+
'Total time (ms)': roundFloat(totalDuration),
|
|
318
|
+
'Instance count': instanceCount,
|
|
319
|
+
'Total render time (ms)': roundFloat(renderDuration),
|
|
320
|
+
'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,
|
|
321
|
+
'Render count': renderCount,
|
|
322
|
+
'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)
|
|
323
|
+
};
|
|
324
|
+
});
|
|
325
|
+
console.table(table);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function printInclusive(flushHistory) {
|
|
329
|
+
var stats = getInclusive(flushHistory);
|
|
330
|
+
var table = stats.map(function (item) {
|
|
331
|
+
var key = item.key;
|
|
332
|
+
var instanceCount = item.instanceCount;
|
|
333
|
+
var inclusiveRenderDuration = item.inclusiveRenderDuration;
|
|
334
|
+
var renderCount = item.renderCount;
|
|
335
|
+
|
|
336
|
+
return {
|
|
337
|
+
'Owner > Component': key,
|
|
338
|
+
'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration),
|
|
339
|
+
'Instance count': instanceCount,
|
|
340
|
+
'Render count': renderCount
|
|
341
|
+
};
|
|
342
|
+
});
|
|
343
|
+
console.table(table);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function printWasted(flushHistory) {
|
|
347
|
+
var stats = getWasted(flushHistory);
|
|
348
|
+
var table = stats.map(function (item) {
|
|
349
|
+
var key = item.key;
|
|
350
|
+
var instanceCount = item.instanceCount;
|
|
351
|
+
var inclusiveRenderDuration = item.inclusiveRenderDuration;
|
|
352
|
+
var renderCount = item.renderCount;
|
|
353
|
+
|
|
354
|
+
return {
|
|
355
|
+
'Owner > Component': key,
|
|
356
|
+
'Inclusive wasted time (ms)': roundFloat(inclusiveRenderDuration),
|
|
357
|
+
'Instance count': instanceCount,
|
|
358
|
+
'Render count': renderCount
|
|
359
|
+
};
|
|
360
|
+
});
|
|
361
|
+
console.table(table);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function printOperations(flushHistory) {
|
|
365
|
+
var stats = getOperations(flushHistory);
|
|
366
|
+
var table = stats.map(function (stat) {
|
|
367
|
+
return {
|
|
368
|
+
'Owner > Node': stat.key,
|
|
369
|
+
'Operation': stat.type,
|
|
370
|
+
'Payload': typeof stat.payload === 'object' ? JSON.stringify(stat.payload) : stat.payload,
|
|
371
|
+
'Flush index': stat.flushIndex,
|
|
372
|
+
'Owner Component ID': stat.ownerID,
|
|
373
|
+
'DOM Component ID': stat.instanceID
|
|
374
|
+
};
|
|
375
|
+
});
|
|
376
|
+
console.table(table);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
var warnedAboutPrintDOM = false;
|
|
380
|
+
function printDOM(measurements) {
|
|
381
|
+
process.env.NODE_ENV !== 'production' ? warning(warnedAboutPrintDOM, '`ReactPerf.printDOM(...)` is deprecated. Use ' + '`ReactPerf.printOperations(...)` instead.') : void 0;
|
|
382
|
+
warnedAboutPrintDOM = true;
|
|
383
|
+
return printOperations(measurements);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
var warnedAboutGetMeasurementsSummaryMap = false;
|
|
387
|
+
function getMeasurementsSummaryMap(measurements) {
|
|
388
|
+
process.env.NODE_ENV !== 'production' ? warning(warnedAboutGetMeasurementsSummaryMap, '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' + '`ReactPerf.getWasted(...)` instead.') : void 0;
|
|
389
|
+
warnedAboutGetMeasurementsSummaryMap = true;
|
|
390
|
+
return getWasted(measurements);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function start() {
|
|
394
|
+
ReactDebugTool.beginProfiling();
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function stop() {
|
|
398
|
+
ReactDebugTool.endProfiling();
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
var ReactPerfAnalysis = {
|
|
402
|
+
getLastMeasurements: getFlushHistory,
|
|
403
|
+
getExclusive: getExclusive,
|
|
404
|
+
getInclusive: getInclusive,
|
|
405
|
+
getWasted: getWasted,
|
|
406
|
+
getOperations: getOperations,
|
|
407
|
+
printExclusive: printExclusive,
|
|
408
|
+
printInclusive: printInclusive,
|
|
409
|
+
printWasted: printWasted,
|
|
410
|
+
printOperations: printOperations,
|
|
411
|
+
start: start,
|
|
412
|
+
stop: stop,
|
|
413
|
+
// Deprecated:
|
|
414
|
+
printDOM: printDOM,
|
|
415
|
+
getMeasurementsSummaryMap: getMeasurementsSummaryMap
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
module.exports = ReactPerfAnalysis;
|