From 7a4aef0d0d23ee0f412d46cb1df3f7100ce842f5 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 6 Jun 2016 20:59:28 +0200 Subject: [PATCH] Tweak ReactPerf warning message and code style (#6977) (cherry picked from commit d101f68bce34a62613a3e86981266111e8950267) --- src/renderers/shared/ReactPerf.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/renderers/shared/ReactPerf.js b/src/renderers/shared/ReactPerf.js index 939bcdba0d..9307ace3af 100644 --- a/src/renderers/shared/ReactPerf.js +++ b/src/renderers/shared/ReactPerf.js @@ -24,18 +24,16 @@ function warnInProduction() { if (alreadyWarned) { return; } - alreadyWarned = true; - if (typeof console !== 'undefined') { console.error( - 'ReactPerf is not supported in the production builds of React.' + + 'ReactPerf is not supported in the production builds of React. ' + 'To collect measurements, please use the development build of React instead.' ); } } -function getFlushHistory() { +function getLastMeasurements() { if (!__DEV__) { warnInProduction(); return []; @@ -44,7 +42,7 @@ function getFlushHistory() { return ReactDebugTool.getFlushHistory(); } -function getExclusive(flushHistory = getFlushHistory()) { +function getExclusive(flushHistory = getLastMeasurements()) { if (!__DEV__) { warnInProduction(); return []; @@ -99,7 +97,7 @@ function getExclusive(flushHistory = getFlushHistory()) { ); } -function getInclusive(flushHistory = getFlushHistory()) { +function getInclusive(flushHistory = getLastMeasurements()) { if (!__DEV__) { warnInProduction(); return []; @@ -172,7 +170,7 @@ function getInclusive(flushHistory = getFlushHistory()) { ); } -function getWasted(flushHistory = getFlushHistory()) { +function getWasted(flushHistory = getLastMeasurements()) { if (!__DEV__) { warnInProduction(); return []; @@ -270,7 +268,7 @@ function getWasted(flushHistory = getFlushHistory()) { ); } -function getOperations(flushHistory = getFlushHistory()) { +function getOperations(flushHistory = getLastMeasurements()) { if (!__DEV__) { warnInProduction(); return []; @@ -409,6 +407,7 @@ function start() { warnInProduction(); return; } + ReactDebugTool.beginProfiling(); } @@ -426,11 +425,12 @@ function isRunning() { warnInProduction(); return false; } + return ReactDebugTool.isProfiling(); } var ReactPerfAnalysis = { - getLastMeasurements: getFlushHistory, + getLastMeasurements, getExclusive, getInclusive, getWasted,