@samitouri / QOS-React-2 / commits / 12ebf33f89

[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.

Pete Hunt committed Feb 12, 2014 at 11:36 UTC 12ebf33f89e90508a28f16472ed2b27e7e7a5079
1 file changed +13 -7
src/core/ReactUpdates.js
+13 -7
@@ -18,6 +18,8 @@
18
19 "use strict";
20
21 +var ReactPerf = require('ReactPerf');
22 +
23 var invariant = require('invariant');
24
25 var dirtyComponents = [];
@@ -75,14 +77,18 @@ function clearDirtyComponents() {
77 dirtyComponents.length = 0;
78 }
79
78 -function flushBatchedUpdates() {
79 - // Run these in separate functions so the JIT can optimize
80 - try {
81 - runBatchedUpdates();
82 - } finally {
83 - clearDirtyComponents();
80 +var flushBatchedUpdates = ReactPerf.measure(
81 + 'ReactUpdates',
82 + 'flushBatchedUpdates',
83 + function() {
84 + // Run these in separate functions so the JIT can optimize
85 + try {
86 + runBatchedUpdates();
87 + } finally {
88 + clearDirtyComponents();
89 + }
90 }
85 -}
91 +);
92
93 /**
94 * Mark a component as needing a rerender, adding an optional callback to a