-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwperf.js
More file actions
executable file
·54 lines (47 loc) · 2.09 KB
/
Copy pathwperf.js
File metadata and controls
executable file
·54 lines (47 loc) · 2.09 KB
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
49
50
51
52
53
54
#!/usr/bin/env node
/* eslint-disable */
const fs = require('fs');
const path = require('path');
const { renderTemplates } = require('./wperf-output/render-templates');
if (!fs.existsSync(path.join(__dirname, 'wperf-output', 'rendered'))) {
renderTemplates();
}
const recordOutputPath = path.join(__dirname, 'wperf-output', 'rendered', 'cpython-multi-sample-output.json')
const listOutputPath = path.join(__dirname, '../', 'src', 'wperf' ,'fixtures', 'wperf-3.5.0.list.json');
const testOutputTextPath = path.join(__dirname, 'wperf-output', 'templates', 'wperf-3.5.0-test-output.txt');
const testOutputJsonPath = path.join(__dirname, 'wperf-output', 'templates', 'wperf-3.7.2.test.json');
const versionOutputJsonPath = path.join(__dirname, '../', 'src', 'wperf' ,'fixtures', 'wperf-3.8.0.version.json');
if (process.argv.length <= 2) {
console.error("No command provided");
process.exit(1);
} else if (process.argv[2] === "record") {
let timeoutId;
const printRecordOutputAndExit = () => {
if (timeoutId !== undefined) {
clearTimeout(timeoutId);
}
const stream = fs.createReadStream(recordOutputPath, { encoding: 'ascii' });
stream.pipe(process.stdout);
};
timeoutId = setTimeout(printRecordOutputAndExit, 500);
process.on('SIGINT', printRecordOutputAndExit);
} else if (process.argv[2] === "list") {
setTimeout(() => {
const stream = fs.createReadStream(listOutputPath, { encoding: 'ascii' });
stream.pipe(process.stdout);
}, 500);
} else if (process.argv[2] === "test") {
const returnJson = process.argv.find(arg => arg === "--json");
setTimeout(() => {
const stream = fs.createReadStream(returnJson ? testOutputJsonPath : testOutputTextPath, { encoding: 'ascii' });
stream.pipe(process.stdout);
}, 500);
} else if (process.argv[2] === "--version") {
setTimeout(() => {
const stream = fs.createReadStream(versionOutputJsonPath, { encoding: 'ascii' });
stream.pipe(process.stdout);
}, 500);
} else {
console.error(`Unknown command: ${process.argv[2]}`);
process.exit(1);
}