mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
added isProfiling() to ReactDebugTool and isRunning() to PerfTools
This commit is contained in:
@@ -115,6 +115,9 @@ var ReactDebugTool = {
|
||||
}
|
||||
}
|
||||
},
|
||||
isProfiling() {
|
||||
return isProfiling;
|
||||
},
|
||||
beginProfiling() {
|
||||
if (__DEV__) {
|
||||
if (isProfiling) {
|
||||
|
||||
@@ -351,6 +351,10 @@ function stop() {
|
||||
ReactDebugTool.endProfiling();
|
||||
}
|
||||
|
||||
function isRunning() {
|
||||
return ReactDebugTool.isProfiling();
|
||||
}
|
||||
|
||||
var ReactPerfAnalysis = {
|
||||
getLastMeasurements: getFlushHistory,
|
||||
getExclusive,
|
||||
@@ -363,6 +367,7 @@ var ReactPerfAnalysis = {
|
||||
printOperations,
|
||||
start,
|
||||
stop,
|
||||
isRunning,
|
||||
// Deprecated:
|
||||
printDOM,
|
||||
getMeasurementsSummaryMap,
|
||||
|
||||
@@ -72,4 +72,14 @@ describe('ReactDebugTool', function() {
|
||||
ReactDebugTool.onTestEvent();
|
||||
expect(console.error.calls.length).toBe(1);
|
||||
});
|
||||
|
||||
it('returns isProfiling state', () => {
|
||||
expect(ReactDebugTool.isProfiling()).toBe(false);
|
||||
|
||||
ReactDebugTool.beginProfiling();
|
||||
expect(ReactDebugTool.isProfiling()).toBe(true);
|
||||
|
||||
ReactDebugTool.endProfiling();
|
||||
expect(ReactDebugTool.isProfiling()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,6 +16,7 @@ describe('ReactPerf', function() {
|
||||
var ReactDOM;
|
||||
var ReactPerf;
|
||||
var ReactTestUtils;
|
||||
var ReactDebugTool;
|
||||
|
||||
var App;
|
||||
var Box;
|
||||
@@ -36,6 +37,7 @@ describe('ReactPerf', function() {
|
||||
ReactDOM = require('ReactDOM');
|
||||
ReactPerf = require('ReactPerf');
|
||||
ReactTestUtils = require('ReactTestUtils');
|
||||
ReactDebugTool = require('ReactDebugTool');
|
||||
|
||||
App = React.createClass({
|
||||
render: function() {
|
||||
@@ -283,4 +285,12 @@ describe('ReactPerf', function() {
|
||||
ReactPerf.printDOM(measurements);
|
||||
expect(console.error.calls.length).toBe(1);
|
||||
});
|
||||
|
||||
it('returns isRunning state', () => {
|
||||
spyOn(ReactDebugTool, 'isProfiling');
|
||||
|
||||
ReactPerf.isRunning();
|
||||
expect(ReactDebugTool.isProfiling.calls.length).toBe(1);
|
||||
expect(ReactPerf.isRunning()).toBe(ReactDebugTool.isProfiling());
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user