Delete the old ReactPerf
Dan Abramov committed
Apr 28, 2016 at 20:43 UTC
5f8f1f6c1603e993ec9f7dab22274ff230ffc19a
19 files changed
+15
-1095
src/renderers/dom/ReactDOM.js
+1
-4
@@ -16,7 +16,6 @@
16
var ReactDOMComponentTree = require('ReactDOMComponentTree');
17
var ReactDefaultInjection = require('ReactDefaultInjection');
18
var ReactMount = require('ReactMount');
19
-var ReactPerf = require('ReactPerf');
19
var ReactReconciler = require('ReactReconciler');
20
var ReactUpdates = require('ReactUpdates');
21
var ReactVersion = require('ReactVersion');
@@ -28,11 +27,9 @@ var warning = require('warning');
27
28
ReactDefaultInjection.inject();
29
31
-var render = ReactPerf.measure('React', 'render', ReactMount.render);
32
-
30
var React = {
31
findDOMNode: findDOMNode,
35
- render: render,
32
+ render: ReactMount.render,
33
unmountComponentAtNode: ReactMount.unmountComponentAtNode,
34
version: ReactVersion,
35
src/renderers/dom/client/ReactDOMIDOperations.js
-5
@@ -13,7 +13,6 @@
13
14
var DOMChildrenOperations = require('DOMChildrenOperations');
15
var ReactDOMComponentTree = require('ReactDOMComponentTree');
16
-var ReactPerf = require('ReactPerf');
16
17
/**
18
* Operations used to process updates to DOM nodes.
@@ -32,8 +31,4 @@ var ReactDOMIDOperations = {
31
},
32
};
33
35
-ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', {
36
- dangerouslyProcessChildrenUpdates: 'dangerouslyProcessChildrenUpdates',
37
-});
38
-
34
module.exports = ReactDOMIDOperations;
src/renderers/dom/client/ReactMount.js
-6
@@ -22,7 +22,6 @@ var ReactElement = require('ReactElement');
22
var ReactFeatureFlags = require('ReactFeatureFlags');
23
var ReactInstrumentation = require('ReactInstrumentation');
24
var ReactMarkupChecksum = require('ReactMarkupChecksum');
25
-var ReactPerf = require('ReactPerf');
25
var ReactReconciler = require('ReactReconciler');
26
var ReactUpdateQueue = require('ReactUpdateQueue');
27
var ReactUpdates = require('ReactUpdates');
@@ -711,9 +710,4 @@ var ReactMount = {
710
},
711
};
712
714
-ReactPerf.measureMethods(ReactMount, 'ReactMount', {
715
- _renderNewRootComponent: '_renderNewRootComponent',
716
- _mountImageIntoNode: '_mountImageIntoNode',
717
-});
718
-
713
module.exports = ReactMount;
src/renderers/dom/client/utils/DOMChildrenOperations.js
-5
@@ -16,7 +16,6 @@ var Danger = require('Danger');
16
var ReactMultiChildUpdateTypes = require('ReactMultiChildUpdateTypes');
17
var ReactDOMComponentTree = require('ReactDOMComponentTree');
18
var ReactInstrumentation = require('ReactInstrumentation');
19
-var ReactPerf = require('ReactPerf');
19
20
var createMicrosoftUnsafeLocalFunction = require('createMicrosoftUnsafeLocalFunction');
21
var setInnerHTML = require('setInnerHTML');
@@ -239,8 +238,4 @@ var DOMChildrenOperations = {
238
239
};
240
242
-ReactPerf.measureMethods(DOMChildrenOperations, 'DOMChildrenOperations', {
243
- replaceDelimitedText: 'replaceDelimitedText',
244
-});
245
-
241
module.exports = DOMChildrenOperations;
src/renderers/dom/shared/CSSPropertyOperations.js
-5
@@ -14,7 +14,6 @@
14
var CSSProperty = require('CSSProperty');
15
var ExecutionEnvironment = require('ExecutionEnvironment');
16
var ReactInstrumentation = require('ReactInstrumentation');
17
-var ReactPerf = require('ReactPerf');
17
18
var camelizeStyleName = require('camelizeStyleName');
19
var dangerousStyleValue = require('dangerousStyleValue');
@@ -238,8 +237,4 @@ var CSSPropertyOperations = {
237
238
};
239
241
-ReactPerf.measureMethods(CSSPropertyOperations, 'CSSPropertyOperations', {
242
- setValueForStyles: 'setValueForStyles',
243
-});
244
-
240
module.exports = CSSPropertyOperations;
src/renderers/dom/shared/DOMPropertyOperations.js
-7
@@ -15,7 +15,6 @@ var DOMProperty = require('DOMProperty');
15
var ReactDOMComponentTree = require('ReactDOMComponentTree');
16
var ReactDOMInstrumentation = require('ReactDOMInstrumentation');
17
var ReactInstrumentation = require('ReactInstrumentation');
18
-var ReactPerf = require('ReactPerf');
18
19
var quoteAttributeValueForBrowser = require('quoteAttributeValueForBrowser');
20
var warning = require('warning');
@@ -250,10 +249,4 @@ var DOMPropertyOperations = {
249
250
};
251
253
-ReactPerf.measureMethods(DOMPropertyOperations, 'DOMPropertyOperations', {
254
- setValueForProperty: 'setValueForProperty',
255
- setValueForAttribute: 'setValueForAttribute',
256
- deleteValueForProperty: 'deleteValueForProperty',
257
-});
258
-
252
module.exports = DOMPropertyOperations;
src/renderers/dom/shared/ReactComponentBrowserEnvironment.js
-9
@@ -13,7 +13,6 @@
13
14
var DOMChildrenOperations = require('DOMChildrenOperations');
15
var ReactDOMIDOperations = require('ReactDOMIDOperations');
16
-var ReactPerf = require('ReactPerf');
16
17
/**
18
* Abstracts away all functionality of the reconciler that requires knowledge of
@@ -40,12 +39,4 @@ var ReactComponentBrowserEnvironment = {
39
40
};
41
43
-ReactPerf.measureMethods(
44
- ReactComponentBrowserEnvironment,
45
- 'ReactComponentBrowserEnvironment',
46
- {
47
- replaceNodeWithMarkup: 'replaceNodeWithMarkup',
48
- }
49
-);
50
-
42
module.exports = ReactComponentBrowserEnvironment;
src/renderers/dom/shared/ReactDOMComponent.js
-6
@@ -34,7 +34,6 @@ var ReactDOMSelect = require('ReactDOMSelect');
34
var ReactDOMTextarea = require('ReactDOMTextarea');
35
var ReactInstrumentation = require('ReactInstrumentation');
36
var ReactMultiChild = require('ReactMultiChild');
37
-var ReactPerf = require('ReactPerf');
37
var ReactServerRenderingTransaction = require('ReactServerRenderingTransaction');
38
39
var emptyFunction = require('emptyFunction');
@@ -1129,11 +1128,6 @@ ReactDOMComponent.Mixin = {
1128
1129
};
1130
1132
-ReactPerf.measureMethods(ReactDOMComponent.Mixin, 'ReactDOMComponent', {
1133
- mountComponent: 'mountComponent',
1134
- receiveComponent: 'receiveComponent',
1135
-});
1136
-
1131
Object.assign(
1132
ReactDOMComponent.prototype,
1133
ReactDOMComponent.Mixin,
src/renderers/dom/shared/ReactDOMTextComponent.js
-10
@@ -15,7 +15,6 @@ var DOMChildrenOperations = require('DOMChildrenOperations');
15
var DOMLazyTree = require('DOMLazyTree');
16
var ReactDOMComponentTree = require('ReactDOMComponentTree');
17
var ReactInstrumentation = require('ReactInstrumentation');
18
-var ReactPerf = require('ReactPerf');
18
19
var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
20
var invariant = require('invariant');
@@ -188,13 +187,4 @@ Object.assign(ReactDOMTextComponent.prototype, {
187
188
});
189
191
-ReactPerf.measureMethods(
192
- ReactDOMTextComponent.prototype,
193
- 'ReactDOMTextComponent',
194
- {
195
- mountComponent: 'mountComponent',
196
- receiveComponent: 'receiveComponent',
197
- }
198
-);
199
-
190
module.exports = ReactDOMTextComponent;
src/renderers/dom/shared/ReactDefaultInjection.js
-9
@@ -15,7 +15,6 @@ var BeforeInputEventPlugin = require('BeforeInputEventPlugin');
15
var ChangeEventPlugin = require('ChangeEventPlugin');
16
var DefaultEventPluginOrder = require('DefaultEventPluginOrder');
17
var EnterLeaveEventPlugin = require('EnterLeaveEventPlugin');
18
-var ExecutionEnvironment = require('ExecutionEnvironment');
18
var HTMLDOMPropertyConfig = require('HTMLDOMPropertyConfig');
19
var ReactComponentBrowserEnvironment =
20
require('ReactComponentBrowserEnvironment');
@@ -91,14 +90,6 @@ function inject() {
90
);
91
92
ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
94
-
95
- if (__DEV__) {
96
- var url = (ExecutionEnvironment.canUseDOM && window.location.href) || '';
97
- if ((/[?&]react_perf\b/).test(url)) {
98
- var ReactDefaultPerf = require('ReactDefaultPerf');
99
- ReactDefaultPerf.start();
100
- }
101
- }
93
}
94
95
module.exports = {
src/renderers/dom/shared/ReactInjection.js
-2
@@ -19,7 +19,6 @@ var ReactClass = require('ReactClass');
19
var ReactEmptyComponent = require('ReactEmptyComponent');
20
var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
21
var ReactNativeComponent = require('ReactNativeComponent');
22
-var ReactPerf = require('ReactPerf');
22
var ReactUpdates = require('ReactUpdates');
23
24
var ReactInjection = {
@@ -31,7 +30,6 @@ var ReactInjection = {
30
EventPluginUtils: EventPluginUtils.injection,
31
EventEmitter: ReactBrowserEventEmitter.injection,
32
NativeComponent: ReactNativeComponent.injection,
34
- Perf: ReactPerf.injection,
33
Updates: ReactUpdates.injection,
34
};
35
src/renderers/native/ReactNativeDOMIDOperations.js
+5
-15
@@ -13,7 +13,6 @@
13
14
var ReactNativeComponentTree = require('ReactNativeComponentTree');
15
var ReactMultiChildUpdateTypes = require('ReactMultiChildUpdateTypes');
16
-var ReactPerf = require('ReactPerf');
16
var UIManager = require('UIManager');
17
18
/**
@@ -71,12 +70,7 @@ var dangerouslyProcessChildrenUpdates = function(inst, childrenUpdates) {
70
* `ReactComponent.DOMIDOperations`.
71
*/
72
var ReactNativeDOMIDOperations = {
74
- dangerouslyProcessChildrenUpdates: ReactPerf.measure(
75
- // FIXME(frantic): #4441289 Hack to avoid modifying react-tools
76
- 'ReactDOMIDOperations',
77
- 'dangerouslyProcessChildrenUpdates',
78
- dangerouslyProcessChildrenUpdates
79
- ),
73
+ dangerouslyProcessChildrenUpdates,
74
75
/**
76
* Replaces a view that exists in the document with markup.
@@ -84,14 +78,10 @@ var ReactNativeDOMIDOperations = {
78
* @param {string} id ID of child to be replaced.
79
* @param {string} markup Mount image to replace child with id.
80
*/
87
- dangerouslyReplaceNodeWithMarkupByID: ReactPerf.measure(
88
- 'ReactDOMIDOperations',
89
- 'dangerouslyReplaceNodeWithMarkupByID',
90
- function(id, mountImage) {
91
- var oldTag = id;
92
- UIManager.replaceExistingNonRootView(oldTag, mountImage);
93
- }
94
- ),
81
+ dangerouslyReplaceNodeWithMarkupByID: function(id, mountImage) {
82
+ var oldTag = id;
83
+ UIManager.replaceExistingNonRootView(oldTag, mountImage);
84
+ },
85
};
86
87
module.exports = ReactNativeDOMIDOperations;
src/renderers/native/ReactNativeMount.js
+9
-21
@@ -15,7 +15,6 @@ var ReactElement = require('ReactElement');
15
var ReactInstrumentation = require('ReactInstrumentation');
16
var ReactNativeContainerInfo = require('ReactNativeContainerInfo');
17
var ReactNativeTagHandles = require('ReactNativeTagHandles');
18
-var ReactPerf = require('ReactPerf');
18
var ReactReconciler = require('ReactReconciler');
19
var ReactUpdateQueue = require('ReactUpdateQueue');
20
var ReactUpdates = require('ReactUpdates');
@@ -171,20 +170,15 @@ var ReactNativeMount = {
170
* @param {View} view View tree image.
171
* @param {number} containerViewID View to insert sub-view into.
172
*/
174
- _mountImageIntoNode: ReactPerf.measure(
175
- // FIXME(frantic): #4441289 Hack to avoid modifying react-tools
176
- 'ReactComponentBrowserEnvironment',
177
- 'mountImageIntoNode',
178
- function(mountImage, containerID) {
179
- // Since we now know that the `mountImage` has been mounted, we can
180
- // mark it as such.
181
- var childTag = mountImage;
182
- UIManager.setChildren(
183
- containerID,
184
- [childTag]
185
- );
186
- }
187
- ),
173
+ _mountImageIntoNode: function(mountImage, containerID) {
174
+ // Since we now know that the `mountImage` has been mounted, we can
175
+ // mark it as such.
176
+ var childTag = mountImage;
177
+ UIManager.setChildren(
178
+ containerID,
179
+ [childTag]
180
+ );
181
+ },
182
183
/**
184
* Standard unmounting of the component that is rendered into `containerID`,
@@ -242,10 +236,4 @@ var ReactNativeMount = {
236
237
};
238
245
-ReactNativeMount.renderComponent = ReactPerf.measure(
246
- 'ReactMount',
247
- '_renderNewRootComponent',
248
- ReactNativeMount.renderComponent
249
-);
250
-
239
module.exports = ReactNativeMount;
src/renderers/shared/reconciler/ReactCompositeComponent.js
-11
@@ -18,7 +18,6 @@ var ReactErrorUtils = require('ReactErrorUtils');
18
var ReactInstanceMap = require('ReactInstanceMap');
19
var ReactInstrumentation = require('ReactInstrumentation');
20
var ReactNodeTypes = require('ReactNodeTypes');
21
-var ReactPerf = require('ReactPerf');
21
var ReactPropTypeLocations = require('ReactPropTypeLocations');
22
var ReactPropTypeLocationNames = require('ReactPropTypeLocationNames');
23
var ReactReconciler = require('ReactReconciler');
@@ -1210,16 +1209,6 @@ var ReactCompositeComponentMixin = {
1209
1210
};
1211
1213
-ReactPerf.measureMethods(
1214
- ReactCompositeComponentMixin,
1215
- 'ReactCompositeComponent',
1216
- {
1217
- mountComponent: 'mountComponent',
1218
- updateComponent: 'updateComponent',
1219
- _renderValidatedComponent: '_renderValidatedComponent',
1220
- }
1221
-);
1222
-
1212
var ReactCompositeComponent = {
1213
1214
Mixin: ReactCompositeComponentMixin,
src/renderers/shared/reconciler/ReactUpdates.js
-6
@@ -15,7 +15,6 @@ var CallbackQueue = require('CallbackQueue');
15
var PooledClass = require('PooledClass');
16
var ReactFeatureFlags = require('ReactFeatureFlags');
17
var ReactInstrumentation = require('ReactInstrumentation');
18
-var ReactPerf = require('ReactPerf');
18
var ReactReconciler = require('ReactReconciler');
19
var Transaction = require('Transaction');
20
@@ -222,11 +221,6 @@ var flushBatchedUpdates = function() {
221
ReactInstrumentation.debugTool.onEndFlush();
222
}
223
};
225
-flushBatchedUpdates = ReactPerf.measure(
226
- 'ReactUpdates',
227
- 'flushBatchedUpdates',
228
- flushBatchedUpdates
229
-);
224
225
/**
226
* Mark a component as needing a rerender, adding an optional callback to a
src/test/ReactDefaultPerf.js
deleted
-361
@@ -1,361 +0,0 @@
1
-/**
2
- * Copyright 2013-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 ReactDefaultPerf
10
- */
11
-
12
-'use strict';
13
-
14
-var DOMProperty = require('DOMProperty');
15
-var ReactDOMComponentTree = require('ReactDOMComponentTree');
16
-var ReactDefaultPerfAnalysis = require('ReactDefaultPerfAnalysis');
17
-var ReactMount = require('ReactMount');
18
-var ReactPerf = require('ReactPerf');
19
-
20
-var performanceNow = require('performanceNow');
21
-var warning = require('warning');
22
-
23
-function roundFloat(val) {
24
- return Math.floor(val * 100) / 100;
25
-}
26
-
27
-function addValue(obj, key, val) {
28
- obj[key] = (obj[key] || 0) + val;
29
-}
30
-
31
-// Composite/text components don't have any built-in ID: we have to make our own
32
-var compositeIDMap;
33
-var compositeIDCounter = 17000;
34
-function getIDOfComposite(inst) {
35
- if (!compositeIDMap) {
36
- compositeIDMap = new WeakMap();
37
- }
38
- if (compositeIDMap.has(inst)) {
39
- return compositeIDMap.get(inst);
40
- } else {
41
- var id = compositeIDCounter++;
42
- compositeIDMap.set(inst, id);
43
- return id;
44
- }
45
-}
46
-
47
-function getID(inst) {
48
- if (inst.hasOwnProperty('_rootNodeID')) {
49
- return inst._rootNodeID;
50
- } else {
51
- return getIDOfComposite(inst);
52
- }
53
-}
54
-
55
-function stripComplexValues(key, value) {
56
- if (typeof value !== 'object' || Array.isArray(value) || value == null) {
57
- return value;
58
- }
59
- var prototype = Object.getPrototypeOf(value);
60
- if (!prototype || prototype === Object.prototype) {
61
- return value;
62
- }
63
- return '<not serializable>';
64
-}
65
-
66
-// This implementation of ReactPerf is going away some time mid 15.x.
67
-// While we plan to keep most of the API, the actual format of measurements
68
-// will change dramatically. To signal this, we wrap them into an opaque-ish
69
-// object to discourage reaching into it until the API stabilizes.
70
-function wrapLegacyMeasurements(measurements) {
71
- return { __unstable_this_format_will_change: measurements };
72
-}
73
-function unwrapLegacyMeasurements(measurements) {
74
- return measurements && measurements.__unstable_this_format_will_change || measurements;
75
-}
76
-
77
-var warnedAboutPrintDOM = false;
78
-var warnedAboutGetMeasurementsSummaryMap = false;
79
-
80
-var ReactDefaultPerf = {
81
- _allMeasurements: [], // last item in the list is the current one
82
- _mountStack: [0],
83
- _compositeStack: [],
84
- _injected: false,
85
-
86
- start: function() {
87
- if (!ReactDefaultPerf._injected) {
88
- ReactPerf.injection.injectMeasure(ReactDefaultPerf.measure);
89
- }
90
-
91
- ReactDefaultPerf._allMeasurements.length = 0;
92
- ReactPerf.enableMeasure = true;
93
- },
94
-
95
- stop: function() {
96
- ReactPerf.enableMeasure = false;
97
- },
98
-
99
- getLastMeasurements: function() {
100
- return wrapLegacyMeasurements(ReactDefaultPerf._allMeasurements);
101
- },
102
-
103
- printExclusive: function(measurements) {
104
- measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
105
- var summary = ReactDefaultPerfAnalysis.getExclusiveSummary(measurements);
106
- console.table(summary.map(function(item) {
107
- return {
108
- 'Component class name': item.componentName,
109
- 'Total inclusive time (ms)': roundFloat(item.inclusive),
110
- 'Exclusive mount time (ms)': roundFloat(item.exclusive),
111
- 'Exclusive render time (ms)': roundFloat(item.render),
112
- 'Mount time per instance (ms)': roundFloat(item.exclusive / item.count),
113
- 'Render time per instance (ms)': roundFloat(item.render / item.count),
114
- 'Instances': item.count,
115
- };
116
- }));
117
- // TODO: ReactDefaultPerfAnalysis.getTotalTime() does not return the correct
118
- // number.
119
- },
120
-
121
- printInclusive: function(measurements) {
122
- measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
123
- var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements);
124
- console.table(summary.map(function(item) {
125
- return {
126
- 'Owner > component': item.componentName,
127
- 'Inclusive time (ms)': roundFloat(item.time),
128
- 'Instances': item.count,
129
- };
130
- }));
131
- console.log(
132
- 'Total time:',
133
- ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
134
- );
135
- },
136
-
137
- getMeasurementsSummaryMap: function(measurements) {
138
- warning(
139
- warnedAboutGetMeasurementsSummaryMap,
140
- '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' +
141
- '`ReactPerf.getWasted(...)` instead.'
142
- );
143
- warnedAboutGetMeasurementsSummaryMap = true;
144
- return ReactDefaultPerf.getWasted(measurements);
145
- },
146
-
147
- getWasted: function(measurements) {
148
- measurements = unwrapLegacyMeasurements(measurements);
149
- var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(
150
- measurements,
151
- true
152
- );
153
- return summary.map(function(item) {
154
- return {
155
- 'Owner > component': item.componentName,
156
- 'Wasted time (ms)': item.time,
157
- 'Instances': item.count,
158
- };
159
- });
160
- },
161
-
162
- printWasted: function(measurements) {
163
- measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
164
- console.table(ReactDefaultPerf.getWasted(measurements));
165
- console.log(
166
- 'Total time:',
167
- ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
168
- );
169
- },
170
-
171
- printDOM: function(measurements) {
172
- warning(
173
- warnedAboutPrintDOM,
174
- '`ReactPerf.printDOM(...)` is deprecated. Use ' +
175
- '`ReactPerf.printOperations(...)` instead.'
176
- );
177
- warnedAboutPrintDOM = true;
178
- return ReactDefaultPerf.printOperations(measurements);
179
- },
180
-
181
- printOperations: function(measurements) {
182
- measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
183
- var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
184
- console.table(summary.map(function(item) {
185
- var result = {};
186
- result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
187
- result.type = item.type;
188
- result.args = JSON.stringify(item.args, stripComplexValues);
189
- return result;
190
- }));
191
- console.log(
192
- 'Total time:',
193
- ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
194
- );
195
- },
196
-
197
- _recordWrite: function(id, fnName, totalTime, args) {
198
- // TODO: totalTime isn't that useful since it doesn't count paints/reflows
199
- var entry =
200
- ReactDefaultPerf
201
- ._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1];
202
- var writes = entry.writes;
203
- writes[id] = writes[id] || [];
204
- writes[id].push({
205
- type: fnName,
206
- time: totalTime,
207
- args: args,
208
- });
209
- },
210
-
211
- measure: function(moduleName, fnName, func) {
212
- return function(...args) {
213
- var totalTime;
214
- var rv;
215
- var start;
216
-
217
- var entry = ReactDefaultPerf._allMeasurements[
218
- ReactDefaultPerf._allMeasurements.length - 1
219
- ];
220
-
221
- if (fnName === '_renderNewRootComponent' ||
222
- fnName === 'flushBatchedUpdates') {
223
- // A "measurement" is a set of metrics recorded for each flush. We want
224
- // to group the metrics for a given flush together so we can look at the
225
- // components that rendered and the DOM operations that actually
226
- // happened to determine the amount of "wasted work" performed.
227
- ReactDefaultPerf._allMeasurements.push(entry = {
228
- exclusive: {},
229
- inclusive: {},
230
- render: {},
231
- counts: {},
232
- writes: {},
233
- displayNames: {},
234
- hierarchy: {},
235
- totalTime: 0,
236
- created: {},
237
- });
238
- start = performanceNow();
239
- rv = func.apply(this, args);
240
- entry.totalTime = performanceNow() - start;
241
- return rv;
242
- } else if (fnName === '_mountImageIntoNode' ||
243
- moduleName === 'ReactDOMIDOperations' ||
244
- moduleName === 'CSSPropertyOperations' ||
245
- moduleName === 'DOMChildrenOperations' ||
246
- moduleName === 'DOMPropertyOperations' ||
247
- moduleName === 'ReactComponentBrowserEnvironment') {
248
- start = performanceNow();
249
- rv = func.apply(this, args);
250
- totalTime = performanceNow() - start;
251
-
252
- if (fnName === '_mountImageIntoNode') {
253
- ReactDefaultPerf._recordWrite('', fnName, totalTime, args[0]);
254
- } else if (fnName === 'dangerouslyProcessChildrenUpdates') {
255
- // special format
256
- args[1].forEach(function(update) {
257
- var writeArgs = {};
258
- if (update.fromIndex !== null) {
259
- writeArgs.fromIndex = update.fromIndex;
260
- }
261
- if (update.toIndex !== null) {
262
- writeArgs.toIndex = update.toIndex;
263
- }
264
- if (update.content !== null) {
265
- writeArgs.content = update.content;
266
- }
267
- ReactDefaultPerf._recordWrite(
268
- args[0]._rootNodeID,
269
- update.type,
270
- totalTime,
271
- writeArgs
272
- );
273
- });
274
- } else {
275
- // basic format
276
- var id = args[0];
277
- if (moduleName === 'EventPluginHub') {
278
- id = id._rootNodeID;
279
- } else if (fnName === 'replaceNodeWithMarkup') {
280
- // Old node is already unmounted; can't get its instance
281
- id = ReactDOMComponentTree.getInstanceFromNode(args[1].node)._rootNodeID;
282
- } else if (fnName === 'replaceDelimitedText') {
283
- id = getID(ReactDOMComponentTree.getInstanceFromNode(args[0]));
284
- } else if (typeof id === 'object') {
285
- id = getID(ReactDOMComponentTree.getInstanceFromNode(args[0]));
286
- }
287
- ReactDefaultPerf._recordWrite(
288
- id,
289
- fnName,
290
- totalTime,
291
- Array.prototype.slice.call(args, 1)
292
- );
293
- }
294
- return rv;
295
- } else if (moduleName === 'ReactCompositeComponent' && (
296
- fnName === 'mountComponent' ||
297
- fnName === 'updateComponent' || // TODO: receiveComponent()?
298
- fnName === '_renderValidatedComponent')) {
299
-
300
- if (this._currentElement.type === ReactMount.TopLevelWrapper) {
301
- return func.apply(this, args);
302
- }
303
-
304
- var rootNodeID = getIDOfComposite(this);
305
- var isRender = fnName === '_renderValidatedComponent';
306
- var isMount = fnName === 'mountComponent';
307
-
308
- var mountStack = ReactDefaultPerf._mountStack;
309
-
310
- if (isRender) {
311
- addValue(entry.counts, rootNodeID, 1);
312
- } else if (isMount) {
313
- entry.created[rootNodeID] = true;
314
- mountStack.push(0);
315
- }
316
-
317
- ReactDefaultPerf._compositeStack.push(rootNodeID);
318
-
319
- start = performanceNow();
320
- rv = func.apply(this, args);
321
- totalTime = performanceNow() - start;
322
-
323
- ReactDefaultPerf._compositeStack.pop();
324
-
325
- if (isRender) {
326
- addValue(entry.render, rootNodeID, totalTime);
327
- } else if (isMount) {
328
- var subMountTime = mountStack.pop();
329
- mountStack[mountStack.length - 1] += totalTime;
330
- addValue(entry.exclusive, rootNodeID, totalTime - subMountTime);
331
- addValue(entry.inclusive, rootNodeID, totalTime);
332
- } else {
333
- addValue(entry.inclusive, rootNodeID, totalTime);
334
- }
335
-
336
- entry.displayNames[rootNodeID] = {
337
- current: this.getName(),
338
- owner: this._currentElement._owner ?
339
- this._currentElement._owner.getName() :
340
- '<root>',
341
- };
342
-
343
- return rv;
344
- } else if (
345
- (moduleName === 'ReactDOMComponent' ||
346
- moduleName === 'ReactDOMTextComponent') &&
347
- (fnName === 'mountComponent' ||
348
- fnName === 'receiveComponent')) {
349
-
350
- rv = func.apply(this, args);
351
- entry.hierarchy[getID(this)] =
352
- ReactDefaultPerf._compositeStack.slice();
353
- return rv;
354
- } else {
355
- return func.apply(this, args);
356
- }
357
- };
358
- },
359
-};
360
-
361
-module.exports = ReactDefaultPerf;
src/test/ReactDefaultPerfAnalysis.js
deleted
-214
@@ -1,214 +0,0 @@
1
-/**
2
- * Copyright 2013-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 ReactDefaultPerfAnalysis
10
- */
11
-
12
-'use strict';
13
-
14
-
15
-// Don't try to save users less than 1.2ms (a number I made up)
16
-var DONT_CARE_THRESHOLD = 1.2;
17
-var DOM_OPERATION_TYPES = {
18
- '_mountImageIntoNode': 'set innerHTML',
19
- INSERT_MARKUP: 'set innerHTML',
20
- MOVE_EXISTING: 'move',
21
- REMOVE_NODE: 'remove',
22
- SET_MARKUP: 'set innerHTML',
23
- TEXT_CONTENT: 'set textContent',
24
- 'setValueForProperty': 'update attribute',
25
- 'setValueForAttribute': 'update attribute',
26
- 'deleteValueForProperty': 'remove attribute',
27
- 'setValueForStyles': 'update styles',
28
- 'replaceNodeWithMarkup': 'replace',
29
- 'replaceDelimitedText': 'replace',
30
-};
31
-
32
-function getTotalTime(measurements) {
33
- // TODO: return number of DOM ops? could be misleading.
34
- // TODO: measure dropped frames after reconcile?
35
- // TODO: log total time of each reconcile and the top-level component
36
- // class that triggered it.
37
- var totalTime = 0;
38
- for (var i = 0; i < measurements.length; i++) {
39
- var measurement = measurements[i];
40
- totalTime += measurement.totalTime;
41
- }
42
- return totalTime;
43
-}
44
-
45
-function getDOMSummary(measurements) {
46
- var items = [];
47
- measurements.forEach(function(measurement) {
48
- Object.keys(measurement.writes).forEach(function(id) {
49
- measurement.writes[id].forEach(function(write) {
50
- items.push({
51
- id: id,
52
- type: DOM_OPERATION_TYPES[write.type] || write.type,
53
- args: write.args,
54
- });
55
- });
56
- });
57
- });
58
- return items;
59
-}
60
-
61
-function getExclusiveSummary(measurements) {
62
- var candidates = {};
63
- var displayName;
64
-
65
- for (var i = 0; i < measurements.length; i++) {
66
- var measurement = measurements[i];
67
- var allIDs = Object.assign(
68
- {},
69
- measurement.exclusive,
70
- measurement.inclusive
71
- );
72
-
73
- for (var id in allIDs) {
74
- displayName = measurement.displayNames[id].current;
75
-
76
- candidates[displayName] = candidates[displayName] || {
77
- componentName: displayName,
78
- inclusive: 0,
79
- exclusive: 0,
80
- render: 0,
81
- count: 0,
82
- };
83
- if (measurement.render[id]) {
84
- candidates[displayName].render += measurement.render[id];
85
- }
86
- if (measurement.exclusive[id]) {
87
- candidates[displayName].exclusive += measurement.exclusive[id];
88
- }
89
- if (measurement.inclusive[id]) {
90
- candidates[displayName].inclusive += measurement.inclusive[id];
91
- }
92
- if (measurement.counts[id]) {
93
- candidates[displayName].count += measurement.counts[id];
94
- }
95
- }
96
- }
97
-
98
- // Now make a sorted array with the results.
99
- var arr = [];
100
- for (displayName in candidates) {
101
- if (candidates[displayName].exclusive >= DONT_CARE_THRESHOLD) {
102
- arr.push(candidates[displayName]);
103
- }
104
- }
105
-
106
- arr.sort(function(a, b) {
107
- return b.exclusive - a.exclusive;
108
- });
109
-
110
- return arr;
111
-}
112
-
113
-function getInclusiveSummary(measurements, onlyClean) {
114
- var candidates = {};
115
- var inclusiveKey;
116
-
117
- for (var i = 0; i < measurements.length; i++) {
118
- var measurement = measurements[i];
119
- var allIDs = Object.assign(
120
- {},
121
- measurement.exclusive,
122
- measurement.inclusive
123
- );
124
- var cleanComponents;
125
-
126
- if (onlyClean) {
127
- cleanComponents = getUnchangedComponents(measurement);
128
- }
129
-
130
- for (var id in allIDs) {
131
- if (onlyClean && !cleanComponents[id]) {
132
- continue;
133
- }
134
-
135
- var displayName = measurement.displayNames[id];
136
-
137
- // Inclusive time is not useful for many components without knowing where
138
- // they are instantiated. So we aggregate inclusive time with both the
139
- // owner and current displayName as the key.
140
- inclusiveKey = displayName.owner + ' > ' + displayName.current;
141
-
142
- candidates[inclusiveKey] = candidates[inclusiveKey] || {
143
- componentName: inclusiveKey,
144
- time: 0,
145
- count: 0,
146
- };
147
-
148
- if (measurement.inclusive[id]) {
149
- candidates[inclusiveKey].time += measurement.inclusive[id];
150
- }
151
- if (measurement.counts[id]) {
152
- candidates[inclusiveKey].count += measurement.counts[id];
153
- }
154
- }
155
- }
156
-
157
- // Now make a sorted array with the results.
158
- var arr = [];
159
- for (inclusiveKey in candidates) {
160
- if (candidates[inclusiveKey].time >= DONT_CARE_THRESHOLD) {
161
- arr.push(candidates[inclusiveKey]);
162
- }
163
- }
164
-
165
- arr.sort(function(a, b) {
166
- return b.time - a.time;
167
- });
168
-
169
- return arr;
170
-}
171
-
172
-function getUnchangedComponents(measurement) {
173
- // For a given reconcile, look at which components did not actually
174
- // render anything to the DOM and return a mapping of their ID to
175
- // the amount of time it took to render the entire subtree.
176
- var cleanComponents = {};
177
- var writes = measurement.writes;
178
- var hierarchy = measurement.hierarchy;
179
- var dirtyComposites = {};
180
- Object.keys(writes).forEach(function(id) {
181
- writes[id].forEach(function(write) {
182
- // Root mounting (innerHTML set) is recorded with an ID of ''
183
- if (id !== '' && hierarchy.hasOwnProperty(id)) {
184
- hierarchy[id].forEach((c) => dirtyComposites[c] = true);
185
- }
186
- });
187
- });
188
- var allIDs = Object.assign({}, measurement.exclusive, measurement.inclusive);
189
-
190
- for (var id in allIDs) {
191
- var isDirty = false;
192
- // See if any of the DOM operations applied to this component's subtree.
193
- if (dirtyComposites[id]) {
194
- isDirty = true;
195
- }
196
- // check if component newly created
197
- if (measurement.created[id]) {
198
- isDirty = true;
199
- }
200
- if (!isDirty && measurement.counts[id] > 0) {
201
- cleanComponents[id] = true;
202
- }
203
- }
204
- return cleanComponents;
205
-}
206
-
207
-var ReactDefaultPerfAnalysis = {
208
- getExclusiveSummary: getExclusiveSummary,
209
- getInclusiveSummary: getInclusiveSummary,
210
- getDOMSummary: getDOMSummary,
211
- getTotalTime: getTotalTime,
212
-};
213
-
214
-module.exports = ReactDefaultPerfAnalysis;
src/test/ReactPerf.js
deleted
-100
@@ -1,100 +0,0 @@
1
-/**
2
- * Copyright 2013-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 ReactPerf
10
- */
11
-
12
-'use strict';
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
- * See also https://facebook.github.io/react/docs/perf.html
18
- */
19
-var ReactPerf = {
20
- /**
21
- * Boolean to enable/disable measurement. Set to false by default to prevent
22
- * accidental logging and perf loss.
23
- */
24
- enableMeasure: false,
25
-
26
- /**
27
- * Holds onto the measure function in use. By default, don't measure
28
- * anything, but we'll override this if we inject a measure function.
29
- */
30
- storedMeasure: _noMeasure,
31
-
32
- /**
33
- * @param {object} object
34
- * @param {string} objectName
35
- * @param {object<string>} methodNames
36
- */
37
- measureMethods: function(object, objectName, methodNames) {
38
- if (__DEV__) {
39
- for (var key in methodNames) {
40
- if (!methodNames.hasOwnProperty(key)) {
41
- continue;
42
- }
43
- object[key] = ReactPerf.measure(
44
- objectName,
45
- methodNames[key],
46
- object[key]
47
- );
48
- }
49
- }
50
- },
51
-
52
- /**
53
- * Use this to wrap methods you want to measure. Zero overhead in production.
54
- *
55
- * @param {string} objName
56
- * @param {string} fnName
57
- * @param {function} func
58
- * @return {function}
59
- */
60
- measure: function(objName, fnName, func) {
61
- if (__DEV__) {
62
- var measuredFunc = null;
63
- var wrapper = function() {
64
- if (ReactPerf.enableMeasure) {
65
- if (!measuredFunc) {
66
- measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
67
- }
68
- return measuredFunc.apply(this, arguments);
69
- }
70
- return func.apply(this, arguments);
71
- };
72
- wrapper.displayName = objName + '_' + fnName;
73
- return wrapper;
74
- }
75
- return func;
76
- },
77
-
78
- injection: {
79
- /**
80
- * @param {function} measure
81
- */
82
- injectMeasure: function(measure) {
83
- ReactPerf.storedMeasure = measure;
84
- },
85
- },
86
-};
87
-
88
-/**
89
- * Simply passes through the measured function, without measuring it.
90
- *
91
- * @param {string} objName
92
- * @param {string} fnName
93
- * @param {function} func
94
- * @return {function}
95
- */
96
-function _noMeasure(objName, fnName, func) {
97
- return func;
98
-}
99
-
100
-module.exports = ReactPerf;
src/test/__tests__/ReactDefaultPerf-test.js
deleted
-299
@@ -1,299 +0,0 @@
1
-/**
2
- * Copyright 2013-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
- * @emails react-core
10
- */
11
-
12
-'use strict';
13
-
14
-describe('ReactDefaultPerf', function() {
15
- var React;
16
- var ReactDOM;
17
- var ReactDOMFeatureFlags;
18
- var ReactDefaultPerf;
19
- var ReactTestUtils;
20
- var ReactDefaultPerfAnalysis;
21
-
22
- var App;
23
- var Box;
24
- var Div;
25
-
26
- beforeEach(function() {
27
- var now = 0;
28
- jest.setMock('fbjs/lib/performanceNow', function() {
29
- return now++;
30
- });
31
-
32
- if (typeof console.table !== 'function') {
33
- console.table = () => {};
34
- console.table.isFake = true;
35
- }
36
-
37
- React = require('React');
38
- ReactDOM = require('ReactDOM');
39
- ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
40
- ReactDefaultPerf = require('ReactDefaultPerf');
41
- ReactTestUtils = require('ReactTestUtils');
42
- ReactDefaultPerfAnalysis = require('ReactDefaultPerfAnalysis');
43
-
44
- App = React.createClass({
45
- render: function() {
46
- return <div><Box /><Box flip={this.props.flipSecond} /></div>;
47
- },
48
- });
49
-
50
- Box = React.createClass({
51
- render: function() {
52
- return <div key={!!this.props.flip}><input /></div>;
53
- },
54
- });
55
-
56
- // ReactPerf only measures composites, so we put everything in one.
57
- Div = React.createClass({
58
- render: function() {
59
- return <div {...this.props} />;
60
- },
61
- });
62
- });
63
-
64
- afterEach(function() {
65
- if (console.table.isFake) {
66
- delete console.table;
67
- }
68
- });
69
-
70
- function measure(fn) {
71
- ReactDefaultPerf.start();
72
- fn();
73
- ReactDefaultPerf.stop();
74
- return ReactDefaultPerf.getLastMeasurements().__unstable_this_format_will_change;
75
- }
76
-
77
- it('should count no-op update as waste', function() {
78
- var container = document.createElement('div');
79
- ReactDOM.render(<App />, container);
80
- var measurements = measure(() => {
81
- ReactDOM.render(<App />, container);
82
- });
83
-
84
- var summary = ReactDefaultPerf.getWasted(measurements);
85
- expect(summary.length).toBe(2);
86
-
87
- /*eslint-disable dot-notation */
88
-
89
- expect(summary[0]['Owner > component']).toBe('<root> > App');
90
- expect(summary[0]['Wasted time (ms)']).not.toBe(0);
91
- expect(summary[0]['Instances']).toBe(1);
92
-
93
- expect(summary[1]['Owner > component']).toBe('App > Box');
94
- expect(summary[1]['Wasted time (ms)']).not.toBe(0);
95
- expect(summary[1]['Instances']).toBe(2);
96
-
97
- /*eslint-enable dot-notation */
98
- });
99
-
100
- it('should count no-op update in child as waste', function() {
101
- var container = document.createElement('div');
102
- ReactDOM.render(<App />, container);
103
-
104
- // Here, we add a Box -- two of the <Box /> updates are wasted time (but the
105
- // addition of the third is not)
106
- var measurements = measure(() => {
107
- ReactDOM.render(<App flipSecond={true} />, container);
108
- });
109
-
110
- var summary = ReactDefaultPerf.getWasted(measurements);
111
- expect(summary.length).toBe(1);
112
-
113
- /*eslint-disable dot-notation */
114
-
115
- expect(summary[0]['Owner > component']).toBe('App > Box');
116
- expect(summary[0]['Wasted time (ms)']).not.toBe(0);
117
- expect(summary[0]['Instances']).toBe(1);
118
-
119
- /*eslint-enable dot-notation */
120
- });
121
-
122
- function expectNoWaste(fn) {
123
- var measurements = measure(fn);
124
- var summary = ReactDefaultPerf.getWasted(measurements);
125
- expect(summary).toEqual([]);
126
- }
127
-
128
- it('should not count initial render as waste', function() {
129
- expectNoWaste(() => {
130
- ReactTestUtils.renderIntoDocument(<App />);
131
- });
132
- });
133
-
134
- it('should not count unmount as waste', function() {
135
- var container = document.createElement('div');
136
- ReactDOM.render(<Div>hello</Div>, container);
137
- expectNoWaste(() => {
138
- ReactDOM.unmountComponentAtNode(container);
139
- });
140
- });
141
-
142
- it('should not count content update as waste', function() {
143
- var container = document.createElement('div');
144
- ReactDOM.render(<Div>hello</Div>, container);
145
- expectNoWaste(() => {
146
- ReactDOM.render(<Div>hello world</Div>, container);
147
- });
148
- });
149
-
150
- it('should not count child addition as waste', function() {
151
- var container = document.createElement('div');
152
- ReactDOM.render(<Div><span /></Div>, container);
153
- expectNoWaste(() => {
154
- ReactDOM.render(<Div><span /><span /></Div>, container);
155
- });
156
- });
157
-
158
- it('should not count child removal as waste', function() {
159
- var container = document.createElement('div');
160
- ReactDOM.render(<Div><span /><span /></Div>, container);
161
- expectNoWaste(() => {
162
- ReactDOM.render(<Div><span /></Div>, container);
163
- });
164
- });
165
-
166
- it('should not count property update as waste', function() {
167
- var container = document.createElement('div');
168
- ReactDOM.render(<Div className="yellow">hey</Div>, container);
169
- expectNoWaste(() => {
170
- ReactDOM.render(<Div className="blue">hey</Div>, container);
171
- });
172
- });
173
-
174
- it('should not count style update as waste', function() {
175
- var container = document.createElement('div');
176
- ReactDOM.render(<Div style={{color: 'yellow'}}>hey</Div>, container);
177
- expectNoWaste(() => {
178
- ReactDOM.render(<Div style={{color: 'blue'}}>hey</Div>, container);
179
- });
180
- });
181
-
182
- it('should not count property removal as waste', function() {
183
- var container = document.createElement('div');
184
- ReactDOM.render(<Div className="yellow">hey</Div>, container);
185
- expectNoWaste(() => {
186
- ReactDOM.render(<Div>hey</Div>, container);
187
- });
188
- });
189
-
190
- it('should not count raw HTML update as waste', function() {
191
- var container = document.createElement('div');
192
- ReactDOM.render(
193
- <Div dangerouslySetInnerHTML={{__html: 'me'}} />,
194
- container
195
- );
196
- expectNoWaste(() => {
197
- ReactDOM.render(
198
- <Div dangerouslySetInnerHTML={{__html: 'you'}} />,
199
- container
200
- );
201
- });
202
- });
203
-
204
- it('should not count child reordering as waste', function() {
205
- var container = document.createElement('div');
206
- ReactDOM.render(<Div><div key="A" /><div key="B" /></Div>, container);
207
- expectNoWaste(() => {
208
- ReactDOM.render(<Div><div key="B" /><div key="A" /></Div>, container);
209
- });
210
- });
211
-
212
- it('should not count text update as waste', function() {
213
- var container = document.createElement('div');
214
- ReactDOM.render(<Div>{'hello'}{'world'}</Div>, container);
215
- expectNoWaste(() => {
216
- ReactDOM.render(<Div>{'hello'}{'friend'}</Div>, container);
217
- });
218
- });
219
-
220
- it('putListener should not be instrumented', function() {
221
- var container = document.createElement('div');
222
- ReactDOM.render(<Div onClick={function() {}}>hey</Div>, container);
223
- var measurements = measure(() => {
224
- ReactDOM.render(<Div onClick={function() {}}>hey</Div>, container);
225
- });
226
-
227
- var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
228
- expect(summary).toEqual([]);
229
- });
230
-
231
- it('deleteListener should not be instrumented', function() {
232
- var container = document.createElement('div');
233
- ReactDOM.render(<Div onClick={function() {}}>hey</Div>, container);
234
- var measurements = measure(() => {
235
- ReactDOM.render(<Div>hey</Div>, container);
236
- });
237
-
238
- var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
239
- expect(summary).toEqual([]);
240
- });
241
-
242
- it('should not fail on input change events', function() {
243
- var container = document.createElement('div');
244
- var onChange = () => {};
245
- var input = ReactDOM.render(
246
- <input checked={true} onChange={onChange} />,
247
- container
248
- );
249
- expectNoWaste(() => {
250
- ReactTestUtils.Simulate.change(input);
251
- });
252
- });
253
-
254
- it('should print a table after calling printOperations', function() {
255
- var container = document.createElement('div');
256
- var measurements = measure(() => {
257
- ReactDOM.render(<Div>hey</Div>, container);
258
- });
259
- spyOn(console, 'table');
260
- ReactDefaultPerf.printOperations(measurements);
261
- expect(console.table.calls.length).toBe(1);
262
- expect(console.table.argsForCall[0][0]).toEqual([{
263
- 'data-reactid': '',
264
- type: 'set innerHTML',
265
- args: ReactDOMFeatureFlags.useCreateElement ?
266
- '{"node":"<not serializable>","children":[],"html":null,"text":null}' :
267
- '"<div data-reactroot=\\"\\" data-reactid=\\"1\\">hey</div>"',
268
- }]);
269
- });
270
-
271
- it('warns once when using getMeasurementsSummaryMap', function() {
272
- var measurements = measure(() => {});
273
- spyOn(console, 'error');
274
- ReactDefaultPerf.getMeasurementsSummaryMap(measurements);
275
- expect(console.error.calls.length).toBe(1);
276
- expect(console.error.argsForCall[0][0]).toContain(
277
- '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' +
278
- '`ReactPerf.getWasted(...)` instead.'
279
- );
280
-
281
- ReactDefaultPerf.getMeasurementsSummaryMap(measurements);
282
- expect(console.error.calls.length).toBe(1);
283
- });
284
-
285
- it('warns once when using printDOM', function() {
286
- var measurements = measure(() => {});
287
- spyOn(console, 'error');
288
- ReactDefaultPerf.printDOM(measurements);
289
- expect(console.error.calls.length).toBe(1);
290
- expect(console.error.argsForCall[0][0]).toContain(
291
- '`ReactPerf.printDOM(...)` is deprecated. Use ' +
292
- '`ReactPerf.printOperations(...)` instead.'
293
- );
294
-
295
- ReactDefaultPerf.printDOM(measurements);
296
- expect(console.error.calls.length).toBe(1);
297
- });
298
-
299
-});