// Builds one self-contained HTML page with the graphs of the simulator runs. // Nothing is uploaded anywhere; open the file in a browser. // // node scripts/sim-report.mjs # turn the runs in .tmp/sim into tables // node scripts/sim-dashboard.mjs # -> .tmp/sim/dashboard.html import { readFileSync, writeFileSync } from "node:fs"; import { dirname, join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; const here = dirname(fileURLToPath(import.meta.url)); const dir = resolve(process.argv[2] ?? join(here, "..", ".tmp", "sim")); const read = (name) => JSON.parse(readFileSync(join(dir, "data", `${name}.json`), "utf8")); const data = { scaling: read("scaling"), timeline: read("timeline"), phases: read("phases"), arrival: read("arrival"), generated: new Date().toISOString().slice(0, 16).replace("T", " "), }; // "<" cannot appear in the JSON, so the data can never close its own script tag const json = JSON.stringify(data).replace(/ json); const out = join(dir, "dashboard.html"); writeFileSync(out, page); console.log(`wrote ${out} (${Math.round(page.length / 1024)} KB, ${data.scaling.length} runs)`);