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:
parent
b0bdd4e45d
commit
340229303f
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
var RCTUIManager = require('NativeModules').UIManager;
|
var RCTUIManager = require('NativeModules').UIManager;
|
||||||
|
|
||||||
|
var performanceNow = require('performanceNow');
|
||||||
|
|
||||||
var installed = false;
|
var installed = false;
|
||||||
var UIManagerStatTracker = {
|
var UIManagerStatTracker = {
|
||||||
install: function() {
|
install: function() {
|
||||||
|
@ -21,15 +23,24 @@ var UIManagerStatTracker = {
|
||||||
}
|
}
|
||||||
installed = true;
|
installed = true;
|
||||||
var statLogHandle;
|
var statLogHandle;
|
||||||
var stats = {};
|
var startTime = 0;
|
||||||
|
var allTimeStats = {};
|
||||||
|
var perFrameStats = {};
|
||||||
function printStats() {
|
function printStats() {
|
||||||
console.log({UIManagerStatTracker: stats});
|
console.log({UIManagerStatTracker: {
|
||||||
|
allTime: allTimeStats,
|
||||||
|
lastFrame: perFrameStats,
|
||||||
|
elapsedMilliseconds: performanceNow() - startTime,
|
||||||
|
}});
|
||||||
statLogHandle = null;
|
statLogHandle = null;
|
||||||
|
perFrameStats = {};
|
||||||
}
|
}
|
||||||
function incStat(key: string, increment: number) {
|
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) {
|
if (!statLogHandle) {
|
||||||
statLogHandle = setImmediate(printStats);
|
startTime = performanceNow();
|
||||||
|
statLogHandle = window.requestAnimationFrame(printStats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var createViewOrig = RCTUIManager.createView;
|
var createViewOrig = RCTUIManager.createView;
|
||||||
|
|
Loading…
Reference in New Issue