spec: parse SPEC CSV files
This commit is contained in:
84
src/spec.ts
84
src/spec.ts
@@ -425,9 +425,8 @@ export function renderConfig(options: ConfigOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
interface SPECResult {
|
export interface SPECResult {
|
||||||
format: string;
|
outputFiles: { [key: string]: string[], };
|
||||||
paths: string[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -442,22 +441,87 @@ export async function watchSPEC<T extends ChildProcessByStdio<null | Writable, R
|
|||||||
// Match & extract string like " format CSV -> /path/to/csv"
|
// Match & extract string like " format CSV -> /path/to/csv"
|
||||||
const formatRe = /^\s*format:\s*(\w+)\s*->\s*(.*)$/;
|
const formatRe = /^\s*format:\s*(\w+)\s*->\s*(.*)$/;
|
||||||
|
|
||||||
return await new Promise<SPECResult[]>((resolve, reject) => {
|
return await new Promise<SPECResult>((resolve, reject) => {
|
||||||
let results: SPECResult[] = [];
|
let outputFiles: { [key: string]: string[]; } = {};
|
||||||
rl.on("line", line => {
|
rl.on("line", line => {
|
||||||
let match;
|
let match;
|
||||||
if ((match = formatRe.exec(line)) != null) {
|
if ((match = formatRe.exec(line)) != null) {
|
||||||
const type = match[1];
|
const type = match[1];
|
||||||
const paths = match[2].split(',').map(path => path.trim());
|
const paths = match[2].split(',').map(path => path.trim());
|
||||||
results.push({
|
outputFiles[type] = paths;
|
||||||
format: type,
|
|
||||||
paths: paths,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// To match if the line contains: "runcpu finished
|
// To match if the line contains: "runcpu finished
|
||||||
if (line.startsWith("runcpu finished")) {
|
if (line.startsWith("runcpu finished")) {
|
||||||
resolve(results);
|
resolve({
|
||||||
|
outputFiles
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
process.on("error", error => reject(error));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SPECResultsTable {
|
||||||
|
baseThreads: string,
|
||||||
|
baseRuntime: string,
|
||||||
|
baseRatio: string,
|
||||||
|
BaseSelected: string,
|
||||||
|
baseStatus: string,
|
||||||
|
peakThreads: string,
|
||||||
|
peakRuntime: string,
|
||||||
|
peakRatio: string,
|
||||||
|
peakSelected: string,
|
||||||
|
peakStatus: string,
|
||||||
|
description?: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseSPECCSVResultsTable(data: string) {
|
||||||
|
const lines = data.split("\n");
|
||||||
|
let index = 0;
|
||||||
|
const eof = () => index >= lines.length;
|
||||||
|
|
||||||
|
let results: { [key: string]: SPECResultsTable; } = {};
|
||||||
|
while (!eof()) {
|
||||||
|
const line = lines[index];
|
||||||
|
if (line.startsWith('"Full Results Table"')) {
|
||||||
|
index += 3;
|
||||||
|
// "Full Results Table"
|
||||||
|
|
||||||
|
// Benchmark,"Base # Threads","Est. Base Run Time","Est. Base Ratio","Base Selected","Base Status","Peak # Threads","Est. Peak Run Time","Est. Peak Ratio","Peak Selected","Peak Status",Description
|
||||||
|
// 600.perlbench_s,1,65.357247,--,0,VE,,,,,,"test iteration #1"
|
||||||
|
// 602.gcc_s,,,,,NR,,,,,NR
|
||||||
|
// 605.mcf_s,,,,,NR,,,,,NR
|
||||||
|
// 620.omnetpp_s,,,,,NR,,,,,NR
|
||||||
|
// 623.xalancbmk_s,,,,,NR,,,,,NR
|
||||||
|
// 625.x264_s,,,,,NR,,,,,NR
|
||||||
|
// 631.deepsjeng_s,,,,,NR,,,,,NR
|
||||||
|
// 641.leela_s,,,,,NR,,,,,NR
|
||||||
|
// 648.exchange2_s,,,,,NR,,,,,NR
|
||||||
|
// 657.xz_s,,,,,NR,,,,,NR
|
||||||
|
while (!eof()) {
|
||||||
|
const dataLine = lines[index];
|
||||||
|
if (dataLine.length == 0)
|
||||||
|
break;
|
||||||
|
const fields: (keyof SPECResultsTable)[] = [
|
||||||
|
"baseThreads",
|
||||||
|
"baseRuntime",
|
||||||
|
"baseRatio",
|
||||||
|
"BaseSelected",
|
||||||
|
"baseStatus",
|
||||||
|
"peakThreads",
|
||||||
|
"peakRuntime",
|
||||||
|
"peakRatio",
|
||||||
|
"peakSelected",
|
||||||
|
"peakStatus",
|
||||||
|
"description",
|
||||||
|
];
|
||||||
|
const splitted = dataLine.split(",");
|
||||||
|
const entries: [keyof SPECResultsTable, string][] = splitted.slice(1).map((name, index) => [fields[index], name]);
|
||||||
|
results[splitted[0]] = (Object.fromEntries(entries) as { [K in keyof SPECResultsTable]: string });
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user