From 1850906e5e557beb2234a1708cfc5fe8e7b4f0bf Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Fri, 9 Nov 2018 14:10:12 -0800 Subject: [PATCH] Use nativeQPLTimestamp for InitializeCore marker point Summary: It seems like `nativePerformanceNow` might not be getting installed in time to be used by InitializeCore on Android. Using PerformanceLogger.currentTimestamp instead, which uses nativeQPLTimestamp (which is what we should be using anyway) Reviewed By: alexeylang Differential Revision: D12875187 fbshipit-source-id: 6eda5d2ed7948ba48c63f76b40b2014511c32494 --- Libraries/Core/InitializeCore.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Libraries/Core/InitializeCore.js b/Libraries/Core/InitializeCore.js index 878971aa1..2a2ca6479 100644 --- a/Libraries/Core/InitializeCore.js +++ b/Libraries/Core/InitializeCore.js @@ -25,8 +25,7 @@ */ 'use strict'; -const startTime = - global.nativePerformanceNow != null ? global.nativePerformanceNow() : null; +const start = Date.now(); require('setUpGlobals'); require('polyfillES6Collections'); @@ -45,8 +44,12 @@ if (__DEV__) { require('setUpDeveloperTools'); } -if (startTime != null) { - const PerformanceLogger = require('PerformanceLogger'); - PerformanceLogger.markPoint('initializeCore_start', startTime); - PerformanceLogger.markPoint('initializeCore_end'); -} +const PerformanceLogger = require('PerformanceLogger'); +// We could just call PerformanceLogger.markPoint at the top of the file, +// but then we'd be excluding the time it took to require PerformanceLogger. +// Instead, we just use Date.now and backdate the timestamp. +PerformanceLogger.markPoint( + 'initializeCore_start', + PerformanceLogger.currentTimestamp() - (Date.now() - start), +); +PerformanceLogger.markPoint('initializeCore_end');