From f50dc884a3f95582e2d57f2514f9fab8e95a3b94 Mon Sep 17 00:00:00 2001 From: jaakko Date: Tue, 14 Apr 2026 09:47:32 +0300 Subject: [PATCH] CodeBench: automaattinen aikaleima ja arkistointi results/-kansioon Output-hakemisto /tmp/kipina-benchmark/2026-04-14T12-30/ Tulokset kopioidaan automaattisesti results/.json/.html --- kipina-codebench/benchmark.mjs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/kipina-codebench/benchmark.mjs b/kipina-codebench/benchmark.mjs index 1d08e8c..2bad71c 100644 --- a/kipina-codebench/benchmark.mjs +++ b/kipina-codebench/benchmark.mjs @@ -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);