mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #6763 from nfcampos/is-running
added isProfiling() to ReactDebugTool and isRunning() to PerfTools
This commit is contained in:
commit
5569d1d40e
4 files changed
+51
No files matched your search
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -283,4 +283,37 @@ describe('ReactPerf', function() {
|
||||
ReactPerf.printDOM(measurements);
|
||||
expect(console.error.calls.length).toBe(1);
|
||||
});
|
||||
|
||||
it('returns isRunning state', () => {
|
||||
expect(ReactPerf.isRunning()).toBe(false);
|
||||
|
||||
ReactPerf.start();
|
||||
expect(ReactPerf.isRunning()).toBe(true);
|
||||
|
||||
ReactPerf.stop();
|
||||
expect(ReactPerf.isRunning()).toBe(false);
|
||||
});
|
||||
|
||||
it('start has no effect when already running', () => {
|
||||
expect(ReactPerf.isRunning()).toBe(false);
|
||||
|
||||
ReactPerf.start();
|
||||
expect(ReactPerf.isRunning()).toBe(true);
|
||||
|
||||
ReactPerf.start();
|
||||
expect(ReactPerf.isRunning()).toBe(true);
|
||||
|
||||
ReactPerf.stop();
|
||||
expect(ReactPerf.isRunning()).toBe(false);
|
||||
});
|
||||
|
||||
it('stop has no effect when already stopped', () => {
|
||||
expect(ReactPerf.isRunning()).toBe(false);
|
||||
|
||||
ReactPerf.stop();
|
||||
expect(ReactPerf.isRunning()).toBe(false);
|
||||
|
||||
ReactPerf.stop();
|
||||
expect(ReactPerf.isRunning()).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user