spec: add Bench types for benchmaark instances
This commit is contained in:
36
spec.ts
36
spec.ts
@@ -2,15 +2,16 @@ import * as path from 'path';
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { promisify } from "util";
|
import { promisify } from "util";
|
||||||
import { SW_AUTOVEC } from "./environment";
|
import { SW_AUTOVEC } from "./environment";
|
||||||
|
import { spec } from 'node:test/reporters';
|
||||||
|
|
||||||
export interface SPECBench {
|
export interface SPECBenchData {
|
||||||
objectNames: string[];
|
objectNames: string[];
|
||||||
num: number;
|
num: number;
|
||||||
name: string;
|
name: string;
|
||||||
exe: string;
|
exe: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const pop2: SPECBench = {
|
export const pop2: SPECBenchData = {
|
||||||
objectNames: [
|
objectNames: [
|
||||||
"netcdf/attr.o",
|
"netcdf/attr.o",
|
||||||
"netcdf/dim.o",
|
"netcdf/dim.o",
|
||||||
@@ -341,16 +342,16 @@ export const pop2: SPECBench = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export function benchpath(specdir: string, bench: SPECBench): string {
|
export function benchpath(specdir: string, bench: SPECBenchData): string {
|
||||||
return path.join(specdir, 'benchspec', 'CPU', `${bench.num}.${bench.name}`);
|
return path.join(specdir, 'benchspec', 'CPU', `${bench.num}.${bench.name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function exepath(specdir: string, bench: SPECBench): string {
|
export function exepath(specdir: string, bench: SPECBenchData): string {
|
||||||
const benchmarkDir = benchpath(specdir, bench);
|
const benchmarkDir = benchpath(specdir, bench);
|
||||||
return path.join(benchmarkDir, 'exe', bench.exe);
|
return path.join(benchmarkDir, 'exe', bench.exe);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildpath(specdir: string, bench: SPECBench): string {
|
export function buildpath(specdir: string, bench: SPECBenchData): string {
|
||||||
const benchmarkDir = benchpath(specdir, bench);
|
const benchmarkDir = benchpath(specdir, bench);
|
||||||
return path.join(benchmarkDir, 'build');
|
return path.join(benchmarkDir, 'build');
|
||||||
}
|
}
|
||||||
@@ -362,9 +363,9 @@ export function setenv(specdir: string): void {
|
|||||||
|
|
||||||
export interface SPEC {
|
export interface SPEC {
|
||||||
newConfig: (name: string, content: string) => Promise<void>;
|
newConfig: (name: string, content: string) => Promise<void>;
|
||||||
benchpath: (bench: SPECBench) => string;
|
benchpath: (bench: SPECBenchData) => string;
|
||||||
exepath: (bench: SPECBench) => string;
|
exepath: (bench: SPECBenchData) => string;
|
||||||
buildpath: (bench: SPECBench) => string;
|
buildpath: (bench: SPECBenchData) => string;
|
||||||
setenv: () => void;
|
setenv: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,6 +381,25 @@ export function mkSPEC(specRoot: string): SPEC {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Bench {
|
||||||
|
benchpath: () => string;
|
||||||
|
exepath: () => string;
|
||||||
|
buildpath: () => string;
|
||||||
|
benchData: () => SPECBenchData;
|
||||||
|
spec: () => SPEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function mkBench(spec: SPEC, bench: SPECBenchData): Bench {
|
||||||
|
return {
|
||||||
|
benchpath: () => spec.benchpath(bench),
|
||||||
|
exepath: () => spec.exepath(bench),
|
||||||
|
buildpath: () => spec.buildpath(bench),
|
||||||
|
benchData: () => bench,
|
||||||
|
spec: () => spec,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export const defaultSPEC = mkSPEC(path.join(SW_AUTOVEC, "spec2017"));
|
export const defaultSPEC = mkSPEC(path.join(SW_AUTOVEC, "spec2017"));
|
||||||
|
|
||||||
const specTemplate = fs.readFileSync("assets/specTemplate.cfg").toString("utf-8");
|
const specTemplate = fs.readFileSync("assets/specTemplate.cfg").toString("utf-8");
|
||||||
|
|||||||
Reference in New Issue
Block a user