mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[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:
committed by
Paul O’Shannessy
parent
d547374847
commit
12ebf33f89
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user