Skip to content

Commit

Permalink
add parsing time measurement and reparse button
Browse files Browse the repository at this point in the history
  • Loading branch information
raptox committed Mar 29, 2020
1 parent 23cae6d commit 129d1a6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
47 changes: 36 additions & 11 deletions app/components/ParseXML.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ export default class ParseXML extends Component {
Save Parsed Data
</Button>
)}
{data && (
<Button
variant="contained"
color="info"
onClick={() => this.openFile(this.state.selectedFile)}
style={buttonStyle}
>
Parse Again
</Button>
)}
<div>
{this.state.selectedFile && (
<h3>Selected File: {this.state.selectedFile}</h3>
Expand All @@ -78,6 +88,9 @@ export default class ParseXML extends Component {
</div>
{data && (
<div>
<div>
Parsing Time: {JSON.parse(data).parseTimeMs.toFixed(2)} ms
</div>
View Parsed Data: <br />
<ReactJson
src={data ? JSON.parse(data) : { empty: true }}
Expand All @@ -89,18 +102,30 @@ export default class ParseXML extends Component {
);
}

openFile() {
let file = dialog.showOpenDialog({
properties: ['openFile'],
filters: [
{ name: 'XML Files', extensions: ['xml'] },
{ name: 'All Files', extensions: ['*'] }
]
});
if (file) {
openFile(selectedFile) {
if (!selectedFile) {
let file = dialog.showOpenDialog({
properties: ['openFile'],
filters: [
{ name: 'XML Files', extensions: ['xml'] },
{ name: 'All Files', extensions: ['*'] }
]
});
if (file) {
this.setState({});
this.setState({ parsing: true, selectedFile: file, parseLog: '' });
parseData(file[0], data => {
this.setState({ parseLog: data, parsing: false });
});
}
} else {
this.setState({});
this.setState({ parsing: true, selectedFile: file, parseLog: '' });
parseData(file[0], data => {
this.setState({
parsing: true,
selectedFile: selectedFile,
parseLog: ''
});
parseData(selectedFile[0], data => {
this.setState({ parseLog: data, parsing: false });
});
}
Expand Down
3 changes: 3 additions & 0 deletions app/utils/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ let applicationColor;

export const parseData = (filename, callback) => {
parseXml(filename, result => {
const startTime = performance.now();
let colorsIndex = 0;
//console.log(`${filename}:`);
let taskdata = result[ROOT_ITEM].task;
Expand Down Expand Up @@ -56,6 +57,8 @@ export const parseData = (filename, callback) => {
// process.exit(1);
// }
// });
const endTime = performance.now();
data.parseTimeMs = endTime - startTime;
callback(JSON.stringify(data, null, 2));
});
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ipm-hpc-v2",
"productName": "IPM-HPC-v2",
"version": "0.8.1",
"version": "0.8.2",
"description": "Interactive Visualization of MPI Performance Data (Bachelor Thesis)",
"scripts": {
"build": "concurrently \"yarn build-main\" \"yarn build-renderer\"",
Expand Down

0 comments on commit 129d1a6

Please sign in to comment.