From 43fc9c5a8cf85f7eb587df23e444f8e9a06ace77 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Tue, 18 Jun 2024 03:19:35 +0800 Subject: [PATCH] spec: add Bench types for benchmaark instances --- spec.ts | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/spec.ts b/spec.ts index e674343..955aa37 100644 --- a/spec.ts +++ b/spec.ts @@ -2,15 +2,16 @@ import * as path from 'path'; import * as fs from "fs"; import { promisify } from "util"; import { SW_AUTOVEC } from "./environment"; +import { spec } from 'node:test/reporters'; -export interface SPECBench { +export interface SPECBenchData { objectNames: string[]; num: number; name: string; exe: string; } -export const pop2: SPECBench = { +export const pop2: SPECBenchData = { objectNames: [ "netcdf/attr.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}`); } -export function exepath(specdir: string, bench: SPECBench): string { +export function exepath(specdir: string, bench: SPECBenchData): string { const benchmarkDir = benchpath(specdir, bench); 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); return path.join(benchmarkDir, 'build'); } @@ -362,9 +363,9 @@ export function setenv(specdir: string): void { export interface SPEC { newConfig: (name: string, content: string) => Promise; - benchpath: (bench: SPECBench) => string; - exepath: (bench: SPECBench) => string; - buildpath: (bench: SPECBench) => string; + benchpath: (bench: SPECBenchData) => string; + exepath: (bench: SPECBenchData) => string; + buildpath: (bench: SPECBenchData) => string; 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")); const specTemplate = fs.readFileSync("assets/specTemplate.cfg").toString("utf-8");