spec: add extract utility functions for data analyzing results
This commit is contained in:
@@ -125,7 +125,25 @@ export interface SPECResultsTable {
|
||||
description?: string,
|
||||
}
|
||||
|
||||
export function parseSPECCSVResultsTable(data: string) {
|
||||
export const extract = (field: keyof SPECResultsTable) => (o: ParsedResult) => {
|
||||
return Object.fromEntries(Object
|
||||
.entries(o)
|
||||
.filter(([_, b]) => b[field] !== '' && b[field] !== undefined && b.baseStatus === 'S')
|
||||
.map(([a, b]) => [a, parseFloat(b[field]!)]));
|
||||
};
|
||||
|
||||
export const extractBaseRatio = extract('baseRatio');
|
||||
|
||||
export const baseRatioFromPath = async (path: string) => {
|
||||
const result = parseSPECCSVResultsTable((await fs.promises.readFile(path)).toString());
|
||||
return extractBaseRatio(result);
|
||||
};
|
||||
|
||||
export interface ParsedResult {
|
||||
[key: string]: SPECResultsTable
|
||||
}
|
||||
|
||||
export function parseSPECCSVResultsTable(data: string): ParsedResult {
|
||||
const lines = data.split("\n");
|
||||
let index = 0;
|
||||
const eof = () => index >= lines.length;
|
||||
|
||||
Reference in New Issue
Block a user