diff --git a/src/spec.ts b/src/spec.ts index b411685..176919b 100644 --- a/src/spec.ts +++ b/src/spec.ts @@ -425,9 +425,8 @@ export function renderConfig(options: ConfigOptions) { } -interface SPECResult { - format: string; - paths: string[]; +export interface SPECResult { + outputFiles: { [key: string]: string[], }; } /** @@ -442,22 +441,87 @@ export async function watchSPEC /path/to/csv" const formatRe = /^\s*format:\s*(\w+)\s*->\s*(.*)$/; - return await new Promise((resolve, reject) => { - let results: SPECResult[] = []; + return await new Promise((resolve, reject) => { + let outputFiles: { [key: string]: string[]; } = {}; rl.on("line", line => { let match; if ((match = formatRe.exec(line)) != null) { const type = match[1]; const paths = match[2].split(',').map(path => path.trim()); - results.push({ - format: type, - paths: paths, - }); + outputFiles[type] = paths; } // To match if the line contains: "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; +}