[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.
This commit is contained in:
Pete Hunt
2014-02-12 12:28:20 -08:00
committed by Paul O’Shannessy
parent d547374847
commit 12ebf33f89
+13 -7
View File
@@ -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