@samitouri / QOS-React-2 / commits / 756bd975b1

[perf] Measure exclusive render time

Piece of https://github.com/facebook/react/pull/962

Pete Hunt committed Feb 12, 2014 at 11:35 UTC 756bd975b1a36c00acc3cacecd96205a92f4501b
1 file changed +22 -18
src/core/ReactCompositeComponent.js
+22 -18
@@ -1267,25 +1267,29 @@ var ReactCompositeComponentMixin = {
1267 /**
1268 * @private
1269 */
1270 - _renderValidatedComponent: function() {
1271 - var renderedComponent;
1272 - var previousContext = ReactContext.current;
1273 - ReactContext.current = this._processChildContext(this._currentContext);
1274 - ReactCurrentOwner.current = this;
1275 - try {
1276 - renderedComponent = this.render();
1277 - } finally {
1278 - ReactContext.current = previousContext;
1279 - ReactCurrentOwner.current = null;
1270 + _renderValidatedComponent: ReactPerf.measure(
1271 + 'ReactCompositeComponent',
1272 + '_renderValidatedComponent',
1273 + function() {
1274 + var renderedComponent;
1275 + var previousContext = ReactContext.current;
1276 + ReactContext.current = this._processChildContext(this._currentContext);
1277 + ReactCurrentOwner.current = this;
1278 + try {
1279 + renderedComponent = this.render();
1280 + } finally {
1281 + ReactContext.current = previousContext;
1282 + ReactCurrentOwner.current = null;
1283 + }
1284 + invariant(
1285 + ReactComponent.isValidComponent(renderedComponent),
1286 + '%s.render(): A valid ReactComponent must be returned. You may have ' +
1287 + 'returned null, undefined, an array, or some other invalid object.',
1288 + this.constructor.displayName || 'ReactCompositeComponent'
1289 + );
1290 + return renderedComponent;
1291 }
1281 - invariant(
1282 - ReactComponent.isValidComponent(renderedComponent),
1283 - '%s.render(): A valid ReactComponent must be returned. You may have ' +
1284 - 'returned null, undefined, an array, or some other invalid object.',
1285 - this.constructor.displayName || 'ReactCompositeComponent'
1286 - );
1287 - return renderedComponent;
1288 - },
1292 + ),
1293
1294 /**
1295 * @private