Skip to content

Commit

Permalink
[ReactNative] Improvements on perf measurement output
Browse files Browse the repository at this point in the history
Summary:
I updated the logging a bit to sum up the time spent in render methods (product code) and the total React time, and then cleaned up some of the other console.logs. I also stopped printing out the majority of React perf output, since it's pretty large and not super useful to print on every load.

I chatted with Jordan a while ago about whether the time between componentDidMount and requestAnimationFrame is a good estimate for how long it takes for React to serialize changes across the bridge and render on the native side, and it sounded like it was a reasonable approximation. I added this to the logging as well, using RCTRenderingPerf still so that it won't console.log when performance measurement isn't enabled.

The total output now looks like: https://phabricator.fb.com/P19764547
If I add up fetch time, relay time, total time spent in React, and time to render across the bridge, I get 915ms out of the total 964ms, although "Total Relay time" and "Total time spent in React" probably has some overlap.

Test Plan:
Sample output: https://phabricator.fb.com/P19764547
Also ran with perf turned off, no errors
  • Loading branch information
jingc authored and oss sync committed Apr 12, 2015
1 parent 4a9d3cb commit d689cb7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Libraries/Utilities/RCTRenderingPerf.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ var RCTRenderingPerf = {
ReactDefaultPerf.stop();
ReactDefaultPerf.printInclusive();
ReactDefaultPerf.printWasted();

var totalRender = 0;
var totalTime = 0;
var measurements = ReactDefaultPerf.getLastMeasurements();
for (var ii = 0; ii < measurements.length; ii++) {
var render = measurements[ii].render;
for (var nodeName in render) {
totalRender += render[nodeName];
}
totalTime += measurements[ii].totalTime;
}
console.log('Total time spent in render(): ' + totalRender + 'ms');

perfModules.forEach((module) => module.stop());
},

Expand Down

0 comments on commit d689cb7

Please sign in to comment.