From 340229303f7d0e4c45167d8eefa25a45a728985c Mon Sep 17 00:00:00 2001 From: Spencer Ahrens Date: Mon, 5 Oct 2015 14:11:51 -0700 Subject: [PATCH] add allTime vs. perBatch UIManager stats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Libraries/ReactNative/UIManagerStatTracker.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Libraries/ReactNative/UIManagerStatTracker.js b/Libraries/ReactNative/UIManagerStatTracker.js index ef9c64b2b..ed17226e6 100644 --- a/Libraries/ReactNative/UIManagerStatTracker.js +++ b/Libraries/ReactNative/UIManagerStatTracker.js @@ -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;