From 12ebf33f89e90508a28f16472ed2b27e7e7a5079 Mon Sep 17 00:00:00 2001 From: Pete Hunt Date: Wed, 12 Feb 2014 11:36:00 -0800 Subject: [PATCH] [perf] Measure flush time This is so we can look at a given flush to determine total time spent in React vs DOM, and which components ended up generating DOM ops. --- src/core/ReactUpdates.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/core/ReactUpdates.js b/src/core/ReactUpdates.js index 19841f2343..c14b67b280 100644 --- a/src/core/ReactUpdates.js +++ b/src/core/ReactUpdates.js @@ -18,6 +18,8 @@ "use strict"; +var ReactPerf = require('ReactPerf'); + var invariant = require('invariant'); var dirtyComponents = []; @@ -75,14 +77,18 @@ function clearDirtyComponents() { dirtyComponents.length = 0; } -function flushBatchedUpdates() { - // Run these in separate functions so the JIT can optimize - try { - runBatchedUpdates(); - } finally { - clearDirtyComponents(); +var flushBatchedUpdates = ReactPerf.measure( + 'ReactUpdates', + 'flushBatchedUpdates', + function() { + // Run these in separate functions so the JIT can optimize + try { + runBatchedUpdates(); + } finally { + clearDirtyComponents(); + } } -} +); /** * Mark a component as needing a rerender, adding an optional callback to a