Библиотека scroll.ts (scrollThrough) с тестами на фикстурах, сценарий scroll.spec.ts: листы форм, отчёты проектов, своды 1/2, projects/summaries, admin-контроль, смена фильтра свода. Параметры PERF_TARGETS/CPU_RATES/REPEATS/ROLES/AXES. Refs #202 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { appendFileSync, mkdirSync } from 'node:fs';
|
|
import path from 'node:path';
|
|
import { PERF_DIR } from './manifest';
|
|
|
|
function pad(n: number) { return String(n).padStart(2, '0'); }
|
|
|
|
export function runId(): string {
|
|
if (process.env.PERF_RUN_ID) return process.env.PERF_RUN_ID;
|
|
const d = new Date();
|
|
return `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}-${pad(d.getHours())}${pad(d.getMinutes())}`;
|
|
}
|
|
|
|
/** Каталог прогона: PERF_RESULTS_DIR (тесты) или perf/results/<run_id>. */
|
|
export function runDir(): string {
|
|
return process.env.PERF_RESULTS_DIR ?? path.join(PERF_DIR, 'results', runId());
|
|
}
|
|
|
|
export interface ResultRecord {
|
|
run_id?: string;
|
|
scenario: string;
|
|
target: string;
|
|
role: string;
|
|
scale: number;
|
|
cpu_rate: number;
|
|
repeat: number;
|
|
metrics: Record<string, number>;
|
|
artifacts: string[];
|
|
incomplete?: boolean;
|
|
skip_reason?: string;
|
|
ts?: string;
|
|
}
|
|
|
|
/** Формат — docstring perf/perfkit/results.py: perf/results/<run_id>/<scenario>.jsonl. */
|
|
export function append(rec: ResultRecord): string {
|
|
const dir = runDir();
|
|
mkdirSync(dir, { recursive: true });
|
|
const full = {
|
|
run_id: runId(),
|
|
incomplete: false,
|
|
ts: new Date().toISOString().replace(/\.\d+Z$/, 'Z'),
|
|
...rec,
|
|
};
|
|
const file = path.join(dir, `${rec.scenario}.jsonl`);
|
|
appendFileSync(file, JSON.stringify(full) + '\n', 'utf-8');
|
|
return file;
|
|
}
|