-
Notifications
You must be signed in to change notification settings - Fork 126
/
PerfPanel.jsx
48 lines (45 loc) · 1.23 KB
/
PerfPanel.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* eslint no-console: 0 */
import React from 'react';
import Perf from 'react-addons-perf';
/**
* Simple panel with buttons for manually starting/stopping perf measurements.
*
* Clicking stop will dump the results of the perf measurements into the Javascript Console.
*/
class PerfPanel extends React.Component {
handleStart() {
Perf.start();
}
handleStop() {
Perf.stop();
const measurements = Perf.getLastMeasurements();
console.log('Inclusive');
Perf.printInclusive(measurements);
console.log('Exclusive');
Perf.printExclusive(measurements);
console.log('Wasted');
Perf.printWasted(measurements);
console.log('DOM');
Perf.printOperations(measurements);
}
render() {
return (
<div className="row panel">
<div className="small-4 columns">
<h3>Perf Controls</h3>
</div>
<div className="small-4 columns">
<button
className="usa-button-primary"
onClick={this.handleStart}>Start</button>
</div>
<div className="small-4 columns">
<button
className="usa-button-primary"
onClick={this.handleStop}>Stop</button>
</div>
</div>
);
}
}
export default PerfPanel;