Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added isProfiling() to ReactDebugTool and isRunning() to PerfTools #6763

Merged
merged 3 commits into from
May 13, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/isomorphic/ReactDebugTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ var ReactDebugTool = {
}
}
},
isProfiling() {
return isProfiling;
},
beginProfiling() {
if (__DEV__) {
if (isProfiling) {
Expand Down
5 changes: 5 additions & 0 deletions src/isomorphic/ReactPerf.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ function stop() {
ReactDebugTool.endProfiling();
}

function isRunning() {
return ReactDebugTool.isProfiling();
}

var ReactPerfAnalysis = {
getLastMeasurements: getFlushHistory,
getExclusive,
Expand All @@ -363,6 +367,7 @@ var ReactPerfAnalysis = {
printOperations,
start,
stop,
isRunning,
// Deprecated:
printDOM,
getMeasurementsSummaryMap,
Expand Down
10 changes: 10 additions & 0 deletions src/isomorphic/__tests__/ReactDebugTool-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
10 changes: 10 additions & 0 deletions src/isomorphic/__tests__/ReactPerf-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('ReactPerf', function() {
var ReactDOM;
var ReactPerf;
var ReactTestUtils;
var ReactDebugTool;

var App;
var Box;
Expand All @@ -36,6 +37,7 @@ describe('ReactPerf', function() {
ReactDOM = require('ReactDOM');
ReactPerf = require('ReactPerf');
ReactTestUtils = require('ReactTestUtils');
ReactDebugTool = require('ReactDebugTool');

App = React.createClass({
render: function() {
Expand Down Expand Up @@ -283,4 +285,12 @@ describe('ReactPerf', function() {
ReactPerf.printDOM(measurements);
expect(console.error.calls.length).toBe(1);
});

it('returns isRunning state', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to test this by running start() and stop().

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed it

spyOn(ReactDebugTool, 'isProfiling');

ReactPerf.isRunning();
expect(ReactDebugTool.isProfiling.calls.length).toBe(1);
expect(ReactPerf.isRunning()).toBe(ReactDebugTool.isProfiling());
});
});