diff --git a/src/bin/cpubench.ts b/src/bin/cpubench.ts index ddb772d..63bf350 100644 --- a/src/bin/cpubench.ts +++ b/src/bin/cpubench.ts @@ -8,6 +8,7 @@ import { promisifySpawn } from '../cli.js'; import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; import chalk from 'chalk'; +import * as fs from 'fs'; // 解析命令行参数 const argv = await yargs(hideBin(process.argv)) @@ -39,6 +40,11 @@ const argv = await yargs(hideBin(process.argv)) description: 'List of benchmarks to run', demandOption: true, }) + .option('workdir-base', { + type: 'string', + description: 'Base directory of workdirs', + demandOption: true, + }) .parse(); @@ -60,13 +66,18 @@ const configFile = path.resolve(cpubenchDir, 'config', `rendered-${uuid}.config` writeFileSync(configFile, cpubenchConfig); +const workdir = path.join(argv.workdirBase, uuid); +console.log(`Using workdir = ${workdir}`); +await fs.promises.mkdir(workdir, { recursive: true }); + const proc = spawn( path.resolve(cpubenchDir, 'cpubench.sh'), [ `--config=${configFile}`, "--skip_verify=1", "--rebuild=1", - "-i=1" + "-i=1", + `--work_dir=${workdir}`, ], { cwd: cpubenchDir } );