add allTime vs. perBatch UIManager stats

Summary: @​public

UIManagerStatTracker now provides allTime and perBatch stats so it's easy to see
how bit each batch is.

Reviewed By: @vjeux

Differential Revision: D2506218

fb-gh-sync-id: 635556185245d2bd6cb149497ea60b503b2523ce
This commit is contained in:
Spencer Ahrens 2015-10-05 14:11:51 -07:00 committed by facebook-github-bot-5
parent b0bdd4e45d
commit 340229303f
1 changed files with 15 additions and 4 deletions

View File

@ -13,6 +13,8 @@
var RCTUIManager = require('NativeModules').UIManager;
var performanceNow = require('performanceNow');
var installed = false;
var UIManagerStatTracker = {
install: function() {
@ -21,15 +23,24 @@ var UIManagerStatTracker = {
}
installed = true;
var statLogHandle;
var stats = {};
var startTime = 0;
var allTimeStats = {};
var perFrameStats = {};
function printStats() {
console.log({UIManagerStatTracker: stats});
console.log({UIManagerStatTracker: {
allTime: allTimeStats,
lastFrame: perFrameStats,
elapsedMilliseconds: performanceNow() - startTime,
}});
statLogHandle = null;
perFrameStats = {};
}
function incStat(key: string, increment: number) {
stats[key] = (stats[key] || 0) + increment;
allTimeStats[key] = (allTimeStats[key] || 0) + increment;
perFrameStats[key] = (perFrameStats[key] || 0) + increment;
if (!statLogHandle) {
statLogHandle = setImmediate(printStats);
startTime = performanceNow();
statLogHandle = window.requestAnimationFrame(printStats);
}
}
var createViewOrig = RCTUIManager.createView;