CodeBench: automaattinen aikaleima ja arkistointi results/-kansioon

Output-hakemisto /tmp/kipina-benchmark/2026-04-14T12-30/
Tulokset kopioidaan automaattisesti results/<aikaleima>.json/.html
This commit is contained in:
2026-04-14 09:47:32 +03:00
parent 7b27800390
commit f50dc884a3

View File

@@ -13,7 +13,7 @@
*/
import { execSync } from 'child_process';
import { writeFileSync, readFileSync, mkdirSync, rmSync, existsSync, readdirSync } from 'fs';
import { writeFileSync, readFileSync, mkdirSync, rmSync, existsSync } from 'fs';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
@@ -29,7 +29,9 @@ const OLLAMA_URL = arg('ollama', process.env.OLLAMA_URL || 'http://localhost:114
const HUB_URL = arg('hub', '');
const FILTER_MODELS = arg('models', '');
const SCENARIO_FILTER = arg('scenarios', 'default');
const OUTPUT_DIR = arg('output', '/tmp/kipina-benchmark');
const TIMESTAMP = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 16);
const OUTPUT_DIR = arg('output', `/tmp/kipina-benchmark/${TIMESTAMP}`);
const RESULTS_DIR = join(__dirname, 'results');
const MAX_FIX_ROUNDS = 2;
// === Promptien lataus tiedostoista ===
@@ -466,18 +468,23 @@ async function main() {
}
// Tallenna JSON + HTML-raportti
writeFileSync(`${OUTPUT_DIR}/results.json`, JSON.stringify(results, null, 2));
const jsonData = JSON.stringify(results, null, 2);
writeFileSync(`${OUTPUT_DIR}/results.json`, jsonData);
const templatePath = join(__dirname, 'report-template.html');
let htmlData = '';
if (existsSync(templatePath)) {
const html = readFileSync(templatePath, 'utf-8').replace(
'/*DATA_PLACEHOLDER*/[]',
JSON.stringify(results)
);
writeFileSync(`${OUTPUT_DIR}/report.html`, html);
htmlData = readFileSync(templatePath, 'utf-8').replace('/*DATA_PLACEHOLDER*/[]', JSON.stringify(results));
writeFileSync(`${OUTPUT_DIR}/report.html`, htmlData);
console.log(`\nRaportti: ${OUTPUT_DIR}/report.html`);
}
console.log(`JSON: ${OUTPUT_DIR}/results.json`);
// Kopioi results/-kansioon aikaleimalla
mkdirSync(RESULTS_DIR, { recursive: true });
writeFileSync(join(RESULTS_DIR, `${TIMESTAMP}.json`), jsonData);
if (htmlData) writeFileSync(join(RESULTS_DIR, `${TIMESTAMP}.html`), htmlData);
console.log(`Arkistoitu: results/${TIMESTAMP}.json`);
// Yhteenveto
const passed = results.filter(r => !r.error && r.testsPassed === r.testsTotal && r.testsTotal > 0);
const partial = results.filter(r => !r.error && r.testsPassed < r.testsTotal && r.testsTotal > 0);