[20] Benchmark: parametrisches Grossgebäude (:gross), bench mit Exporten und Doc-Undo, Frame-Zeit-Spec
This commit is contained in:
6 files changed
+268
-3
No files matched your search
@@ -0,0 +1,81 @@
|
||||
// Frame-Zeiten im 2D-Plan am Grossgebäude ([20]): öffnet das parametrische Testgebäude (8 × 15,
|
||||
// `model/sampleProjectBig.ts`, per CLI als .obp erzeugt) und misst beim Zoomen und Schwenken die
|
||||
// requestAnimationFrame-Abstände. Gibt p50/p95/max aus; geprüft wird nur eine grosse Obergrenze (nicht flackernd).
|
||||
// Läuft nur mit E2E_PERF=1 (`npm run e2e:perf`), damit die normale Suite nicht langsamer wird.
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { mkdirSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { discardIfAsked, expect, fileMenu, startNewProject, test } from "./app";
|
||||
|
||||
const BIG_OBP = resolve(".tmp-e2e/gross.obp");
|
||||
|
||||
function pct(sorted: number[], q: number): number {
|
||||
return sorted[Math.min(sorted.length - 1, Math.floor(q * sorted.length))] ?? 0;
|
||||
}
|
||||
|
||||
test.describe("@perf Grossgebäude", () => {
|
||||
test.skip(!process.env.E2E_PERF, "Messung nur mit E2E_PERF=1");
|
||||
|
||||
test("2D-Plan: Zoom und Schwenken, Frame-Zeiten", async ({ page }) => {
|
||||
test.setTimeout(60_000);
|
||||
mkdirSync(resolve(".tmp-e2e"), { recursive: true });
|
||||
execFileSync("node", ["dist-cli/dossier-cli.mjs", ":gross", "migrate", "--out", BIG_OBP], { stdio: "inherit" });
|
||||
|
||||
await startNewProject(page);
|
||||
const chooser = page.waitForEvent("filechooser");
|
||||
await fileMenu(page, "Projekt öffnen");
|
||||
await (await chooser).setFiles(BIG_OBP);
|
||||
await discardIfAsked(page);
|
||||
await expect(page.locator(".project-name")).toHaveText(/Grossgebäude 8×15/, { timeout: 30_000 });
|
||||
const svg = page.locator("svg.plan-svg");
|
||||
await expect(svg).toBeVisible({ timeout: 30_000 });
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
const box = (await svg.boundingBox())!;
|
||||
const cx = box.x + box.width / 2;
|
||||
const cy = box.y + box.height / 2;
|
||||
await page.mouse.move(cx, cy);
|
||||
|
||||
const start = () => page.evaluate(() => {
|
||||
const w = window as unknown as { __frames: number[]; __run: boolean };
|
||||
w.__frames = [];
|
||||
w.__run = true;
|
||||
let last = performance.now();
|
||||
const tick = (t: number) => {
|
||||
w.__frames.push(t - last);
|
||||
last = t;
|
||||
if (w.__run) requestAnimationFrame(tick);
|
||||
};
|
||||
requestAnimationFrame(tick);
|
||||
});
|
||||
const stop = () => page.evaluate(() => {
|
||||
const w = window as unknown as { __frames: number[]; __run: boolean };
|
||||
w.__run = false;
|
||||
return w.__frames.slice(1);
|
||||
});
|
||||
|
||||
const phases: Record<string, number[]> = {};
|
||||
// Zoom: rein und wieder heraus in kleinen Rad-Schritten.
|
||||
await start();
|
||||
for (let k = 0; k < 40; k++) { await page.mouse.wheel(0, k < 20 ? -120 : 120); await page.waitForTimeout(16); }
|
||||
await page.waitForTimeout(300);
|
||||
phases.zoom = await stop();
|
||||
// Schwenken: mittlere Taste ziehen.
|
||||
await start();
|
||||
await page.mouse.down({ button: "middle" });
|
||||
for (let k = 1; k <= 60; k++) await page.mouse.move(cx + Math.sin(k / 6) * 300, cy + Math.cos(k / 6) * 150, { steps: 2 });
|
||||
await page.mouse.up({ button: "middle" });
|
||||
phases.pan = await stop();
|
||||
|
||||
for (const [name, f] of Object.entries(phases)) {
|
||||
const s = [...f].sort((a, b) => a - b);
|
||||
const line = `Frame-Zeiten ${name}: n=${s.length} p50=${pct(s, 0.5).toFixed(1)} ms p95=${pct(s, 0.95).toFixed(1)} ms max=${(s[s.length - 1] ?? 0).toFixed(1)} ms (Engine ${await svg.getAttribute("data-engine")})`;
|
||||
console.log(line);
|
||||
test.info().annotations.push({ type: `frames-${name}`, description: line });
|
||||
expect(s.length, `Frames ${name}`).toBeGreaterThan(5);
|
||||
// Grosse Obergrenze (Software-Rendering im Container): fängt nur Ausreisser wie Sekunden-Hänger.
|
||||
expect(pct(s, 0.5), `p50 ${name}`).toBeLessThan(500);
|
||||
expect(pct(s, 0.95), `p95 ${name}`).toBeLessThan(2000);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -13,6 +13,7 @@
|
||||
"test:watch": "vitest",
|
||||
"check": "node scripts/check.mjs",
|
||||
"e2e": "playwright test",
|
||||
"e2e:perf": "E2E_PERF=1 playwright test bigBuilding",
|
||||
"build:render-png": "cargo build --release --features png --bin render_png --manifest-path src-tauri/render3d/Cargo.toml",
|
||||
"gen:types": "DOSSIER_GEN_TYPES=1 cargo test --quiet --lib --manifest-path src-tauri/core/Cargo.toml ts_types_aktuell",
|
||||
"build:cli": "esbuild src/cli/main.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist-cli/dossier-cli.mjs --log-level=warning",
|
||||
|
||||
+43
-3
@@ -30,6 +30,7 @@
|
||||
// dossier-cli <projekt.obp> mcp MCP-Server (stdio) auf der Datei: Werkzeuge aus core/aiToolDefs.ts
|
||||
// dossier-cli mcp --app [--port 7979] [--token …] MCP-Brücke zur offenen App ([9], KI-Zugriff in den Einstellungen)
|
||||
// dossier-cli <projekt.obp> bench [--runs 10] Zeitprofil der Ableitungen (ms je Aufruf)
|
||||
// dossier-cli bench --big [--floors 8 --apartments 15] dasselbe am parametrischen Grossgebäude (`:gross`, [20])
|
||||
//
|
||||
// Statt einer Datei nimmt `:beispiel` das eingebaute Demo-Haus (sampleProject), `:musterhaus-komplex` das
|
||||
// grosse Beispiel (model/sampleProjectComplex.ts; als Datei: `dossier-cli :musterhaus-komplex migrate --out mk.obp`).
|
||||
@@ -109,6 +110,8 @@ import {
|
||||
projectWarnings,
|
||||
sampleProject,
|
||||
buildComplexSampleProject,
|
||||
buildBigSampleProject,
|
||||
withDocument,
|
||||
AI_BRIDGE_DEFAULT_PORT,
|
||||
} from "../core";
|
||||
import type { Project } from "../core";
|
||||
@@ -165,9 +168,10 @@ function fail(msg: string): never {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function loadProject(path: string): Project {
|
||||
function loadProject(path: string, args: Args): Project {
|
||||
if (path === ":beispiel") return sampleProject;
|
||||
if (path === ":musterhaus-komplex") return buildComplexSampleProject();
|
||||
if (path === ":gross") return buildBigSampleProject({ floors: Number(args.flags.get("floors") ?? 8), apartments: Number(args.flags.get("apartments") ?? 15) });
|
||||
let text: string;
|
||||
try {
|
||||
text = readFileSync(path, "utf8");
|
||||
@@ -302,6 +306,8 @@ async function pointCloudInfo(args: Args, src: string | undefined): Promise<numb
|
||||
export async function run(argv: string[]): Promise<number> {
|
||||
const args = parseArgs(argv);
|
||||
const convertMode = args.positional[0] === "convert";
|
||||
// `dossier-cli bench --big [--floors 8 --apartments 15]` = `dossier-cli :gross bench` ([20]).
|
||||
if (args.positional[0] === "bench" && args.flags.has("big")) args.positional.unshift(":gross");
|
||||
const [file, command, ...rest] = args.positional;
|
||||
if (file === "bcf-info") return runBcfInfo(command);
|
||||
if (file === "pointcloud-info") return pointCloudInfo(args, command);
|
||||
@@ -326,7 +332,7 @@ export async function run(argv: string[]): Promise<number> {
|
||||
});
|
||||
await initCore();
|
||||
if (convertMode) return convert(command, rest[0], args);
|
||||
const project = loadProject(file);
|
||||
const project = loadProject(file, args);
|
||||
let code = 0;
|
||||
if (command) code = await execute(project, file, command, rest, args);
|
||||
return code === 0 ? runCmds(project, file, args) : code;
|
||||
@@ -387,7 +393,7 @@ function importDoc(project: Project) {
|
||||
/** Liest Eingabe nach Endung in ein Projekt: obp direkt, dxf/dwg als 2D-Zeichnung + Meshes, ifc als Kontext-Meshes (`--elements`: Bauteile). */
|
||||
async function importAny(path: string, args: Args): Promise<Project> {
|
||||
const ext = extOf(path);
|
||||
if (ext === "obp" || ext === "json" || path === ":beispiel" || path === ":musterhaus-komplex") return loadProject(path);
|
||||
if (ext === "obp" || ext === "json" || path === ":beispiel" || path === ":musterhaus-komplex") return loadProject(path, args);
|
||||
let bytes: Uint8Array;
|
||||
try {
|
||||
bytes = new Uint8Array(readFileSync(path));
|
||||
@@ -831,6 +837,7 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
const sec = findLevel(project, ["section"], undefined);
|
||||
const elev = findLevel(project, ["elevation"], undefined);
|
||||
const rows: Array<[string, number]> = [];
|
||||
process.stdout.write(`${project.name}: ${project.walls.length} Wände, ${(project.openings?.length ?? 0)} Öffnungen, ${(project.rooms?.length ?? 0)} Räume, ${project.stairs?.length ?? 0} Treppen\n`);
|
||||
const time = async (name: string, f: () => unknown | Promise<unknown>, n = runs) => {
|
||||
await f(); // Aufwärmen (füllt Caches wie roofGeometry)
|
||||
const t0 = performance.now();
|
||||
@@ -850,6 +857,39 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
const w0 = project.walls[0];
|
||||
await time("Op: patch+apply (1 Wand)", () => applyOps(project, patchItem(project, "walls", w0.id, { height: (w0.height ?? 2.6) + 0.1 })), runs * 20);
|
||||
}
|
||||
// Exporte ([20]): DXF eines Geschosses, IFC des ganzen Modells.
|
||||
if (floor) {
|
||||
const world = projectToWorldCoords(project);
|
||||
await loadFileio();
|
||||
await time("DXF (1 Geschoss)", () => buildPlanDxf(generatePlan(world, floor.id, allCodes), world, { scaleDenominator: scale, levelId: floor.id }), Math.max(3, runs / 2));
|
||||
}
|
||||
await loadFileio();
|
||||
await time("IFC (Modell)", () => exportIfcSpf(project, {}), Math.max(2, runs / 5));
|
||||
// Ops am Dokument ([20]): Stapel von Änderungen annehmen (ein Verlaufsschritt), Undo, Redo.
|
||||
if (project.walls.length) {
|
||||
const batch = project.walls.slice(0, Math.min(200, project.walls.length));
|
||||
const opsFor = (p: Project, dh: number) => batch.flatMap((w) => patchItem(p, "walls", w.id, { height: (w.height ?? 2.6) + dh }));
|
||||
withDocument(project, (doc) => {
|
||||
let cur = project;
|
||||
const lap = (name: string, f: () => void, n = Math.max(3, runs)) => {
|
||||
f();
|
||||
const t0 = performance.now();
|
||||
for (let i = 0; i < n; i++) f();
|
||||
rows.push([name, (performance.now() - t0) / n]);
|
||||
};
|
||||
let k = 0;
|
||||
lap(`Doc: commit (${batch.length} Wände, 1 Schritt)`, () => {
|
||||
const r = doc.commit(cur, opsFor(cur, 0.01 * ++k), undefined, Date.now());
|
||||
if ("project" in r) cur = r.project;
|
||||
});
|
||||
lap(`Doc: undo (${batch.length} Wände)`, () => { cur = doc.undo(cur) ?? cur; }, Math.max(3, runs / 2));
|
||||
lap(`Doc: redo (${batch.length} Wände)`, () => { cur = doc.redo(cur) ?? cur; }, Math.max(3, runs / 2));
|
||||
lap("Doc: commit (1 Wand)", () => {
|
||||
const r = doc.commit(cur, opsFor({ ...cur, walls: cur.walls.slice(0, 1) } as Project, 0.01 * ++k).slice(0, 1), undefined, Date.now());
|
||||
if ("project" in r) cur = r.project;
|
||||
}, runs * 5);
|
||||
});
|
||||
}
|
||||
for (const [n, ms] of rows) process.stdout.write(`${n.padEnd(28)} ${ms.toFixed(2).padStart(9)} ms\n`);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ export { ProjectDocument, sharedDocument } from "./document";
|
||||
export { withDocument } from "./document";
|
||||
export { emptyProject } from "../model/sampleProject";
|
||||
export { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
export { buildBigSampleProject } from "../model/sampleProjectBig";
|
||||
export { readPointCloud, readPointCloudFlat, isPointCloudFile, DEFAULT_MAX_POINTS } from "../io/pointCloud";
|
||||
export type { PointCloudData, PointCloudOptions, PointCloudReport } from "../io/pointCloud";
|
||||
export { readPdfVector, pdfImport, pdfPageInfo, isPdfFile, PDF_SCALES } from "../io/pdfVector";
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Grossgebäude ([20]): parametrisch, deterministisch, gültig; Ableitungen rechnen.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildBigSampleProject } from "./sampleProjectBig";
|
||||
import { validateProject } from "../core/ops";
|
||||
import { generatePlan } from "../plan/generatePlan";
|
||||
import { projectToModel3d } from "../plan/toWalls3d";
|
||||
import { collectVisibleCodes } from "./types";
|
||||
|
||||
describe("Grossgebäude", () => {
|
||||
it("Standard: ≈ 4000 Wände + Öffnungen, deterministisch", () => {
|
||||
const p = buildBigSampleProject();
|
||||
const n = p.walls.length + (p.openings?.length ?? 0);
|
||||
expect(n).toBeGreaterThan(3500);
|
||||
expect(n).toBeLessThan(4500);
|
||||
expect(p.rooms?.length).toBe(8 * 15 * 9);
|
||||
expect(JSON.stringify(buildBigSampleProject())).toBe(JSON.stringify(p));
|
||||
expect(validateProject(p)).toEqual([]);
|
||||
});
|
||||
|
||||
it("klein parametrisiert: Plan und 3D rechnen", () => {
|
||||
const p = buildBigSampleProject({ floors: 2, apartments: 2 });
|
||||
expect(p.walls.length).toBe(2 * (2 * 15 + 4));
|
||||
const plan = generatePlan(p, "g0", collectVisibleCodes(p.layers));
|
||||
expect(plan).toBeTruthy();
|
||||
expect(projectToModel3d(p)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,115 @@
|
||||
// Grosses Testgebäude für Leistungsmessungen ([20]): N Geschosse × M Wohnungen, parametrisch und
|
||||
// deterministisch (feste ids, keine Zufallszahlen). Nur Modell-Literal — braucht den Kern nicht.
|
||||
// Kein Menüpunkt in der App; genutzt von `dossier-cli :gross bench`, Tests und dem Frame-Zeit-Spec
|
||||
// (`e2e/bigBuilding.spec.ts`, per `window.__dossierLoadBig`).
|
||||
//
|
||||
// Aufbau je Geschoss: M Wohnungen (6 × 10 m) in einer Reihe entlang x, je 3 × 3 Zellen (Raum + Innenwände
|
||||
// mit Tür), 3 Fenster Süd und Nord; am Ostende ein Treppenkern mit Treppe. Decke je Geschoss, Satteldach.
|
||||
|
||||
import type { Opening, Project, Room, Vec2, Wall } from "./types";
|
||||
import { sampleProject } from "./sampleProject";
|
||||
|
||||
export interface BigBuildingOptions {
|
||||
/** Anzahl Geschosse (Standard 8). */
|
||||
floors?: number;
|
||||
/** Wohnungen je Geschoss (Standard 15). */
|
||||
apartments?: number;
|
||||
}
|
||||
|
||||
const P = (x: number, y: number): Vec2 => ({ x, y });
|
||||
const W = 6; // Wohnungsbreite
|
||||
const D = 10; // Wohnungstiefe
|
||||
const FH = 3; // Geschosshöhe
|
||||
const CORE = 3; // Breite des Treppenkerns
|
||||
|
||||
export function buildBigSampleProject(opts: BigBuildingOptions = {}): Project {
|
||||
const nf = Math.max(1, Math.floor(opts.floors ?? 8));
|
||||
const na = Math.max(1, Math.floor(opts.apartments ?? 15));
|
||||
const total = na * W + CORE;
|
||||
const walls: Wall[] = [];
|
||||
const openings: Opening[] = [];
|
||||
const rooms: Room[] = [];
|
||||
const ceilings: NonNullable<Project["ceilings"]> = [];
|
||||
const stairs: NonNullable<Project["stairs"]> = [];
|
||||
const levels = Array.from({ length: nf }, (_, i) => ({
|
||||
id: `g${i}`, name: i === 0 ? "Erdgeschoss" : `${i}. Obergeschoss`, kind: "floor" as const, visible: true, locked: false,
|
||||
floorHeight: FH, cutHeight: 1.0, baseElevation: i * FH,
|
||||
}));
|
||||
|
||||
for (let f = 0; f < nf; f++) {
|
||||
const fl = `g${f}`;
|
||||
let n = 0;
|
||||
let on = 0;
|
||||
const wall = (a: Vec2, b: Vec2, type: string, ext = false): string => {
|
||||
const id = `${fl}-w${++n}`;
|
||||
walls.push({ id, type: "wall", floorId: fl, categoryCode: "20", start: a, end: b, wallTypeId: type, height: FH, ...(ext ? { isExternal: true, loadBearing: true } : {}) });
|
||||
return id;
|
||||
};
|
||||
const win = (host: string, position: number) => openings.push({
|
||||
id: `${fl}-o${++on}`, type: "opening", hostWallId: host, categoryCode: "21", kind: "window", typeId: "window-standard",
|
||||
position, width: 1.2, height: 1.4, sillHeight: 0.9, isExternal: true,
|
||||
});
|
||||
const door = (host: string, position: number) => openings.push({
|
||||
id: `${fl}-o${++on}`, type: "opening", hostWallId: host, categoryCode: "21", kind: "door", typeId: "door-standard",
|
||||
position, width: 0.9, height: 2.1, sillHeight: 0, swing: "left", hinge: "start",
|
||||
});
|
||||
|
||||
for (let a = 0; a < na; a++) {
|
||||
const x0 = a * W;
|
||||
const s = wall(P(x0, 0), P(x0 + W, 0), "aw", true);
|
||||
const nn = wall(P(x0 + W, D), P(x0, D), "aw", true);
|
||||
for (let i = 0; i < 3; i++) { win(s, 0.4 + 2 * i); win(nn, 0.4 + 2 * i); }
|
||||
wall(P(x0, 0), P(x0, D), "iw"); // Wohnungstrennwand
|
||||
for (const dx of [2, 4]) {
|
||||
for (let j = 0; j < 3; j++) door(wall(P(x0 + dx, j * 3.3), P(x0 + dx, j === 2 ? D : (j + 1) * 3.3), "iw"), 1.2);
|
||||
}
|
||||
for (const dy of [3.3, 6.6]) {
|
||||
for (let i = 0; i < 3; i++) door(wall(P(x0 + i * 2, dy), P(x0 + (i + 1) * 2, dy), "iw"), 0.55);
|
||||
}
|
||||
for (let i = 0; i < 3; i++) for (let j = 0; j < 3; j++) {
|
||||
const bx = x0 + i * 2 + 0.1, by = j * 3.3 + 0.1;
|
||||
rooms.push({
|
||||
id: `${fl}-r${a}-${i}${j}`, type: "room", floorId: fl, categoryCode: "60", siaCategory: "HNF", name: `Zimmer ${a + 1}.${i * 3 + j + 1}`,
|
||||
boundary: [P(bx, by), P(bx + 1.8, by), P(bx + 1.8, by + 3.1), P(bx, by + 3.1)], color: "#bcd0e4",
|
||||
} as Room);
|
||||
}
|
||||
}
|
||||
// Treppenkern am Ostende.
|
||||
const cx = na * W;
|
||||
wall(P(cx, 0), P(cx + CORE, 0), "aw", true);
|
||||
wall(P(cx + CORE, 0), P(cx + CORE, D), "aw", true);
|
||||
wall(P(cx + CORE, D), P(cx, D), "aw", true);
|
||||
wall(P(cx, 0), P(cx, D), "iw");
|
||||
if (f < nf - 1) {
|
||||
stairs.push({ id: `${fl}-tr`, type: "stair", floorId: fl, categoryCode: "40", shape: "straight", typeId: "stair-standard", start: P(cx + 1, 0.5), dir: P(0, 1), runLength: 4.5, width: 1.0, totalRise: FH, stepCount: 17, up: true });
|
||||
}
|
||||
ceilings.push({
|
||||
id: `${fl}-decke`, type: "ceiling", floorId: fl, categoryCode: "30", outline: [P(0, 0), P(total, 0), P(total, D), P(0, D)],
|
||||
wallTypeId: "aw", ceilingTypeId: "dg-massiv",
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
...sampleProject,
|
||||
id: "gross",
|
||||
name: `Grossgebäude ${nf}×${na}`,
|
||||
drawingLevels: [
|
||||
...levels,
|
||||
{ id: "schnitt-a", name: "Schnitt A", kind: "section", visible: true, locked: false, linePoints: [P(total / 2, -2), P(total / 2, D + 2)], directionSign: 1 },
|
||||
{ id: "ansicht-sued", name: "Ansicht Süd", kind: "elevation", visible: true, locked: false, linePoints: [P(-2, -3), P(total + 2, -3)], directionSign: 1, shadows: true },
|
||||
],
|
||||
walls,
|
||||
openings,
|
||||
ceilings,
|
||||
stairs,
|
||||
rooms,
|
||||
roofs: [{
|
||||
id: "dach", type: "roof", floorId: `g${nf - 1}`, categoryCode: "31", outline: [P(0, 0), P(total, 0), P(total, D), P(0, D)],
|
||||
shape: "sattel", pitchDeg: 30, overhang: 0.4, ridgeAxis: "x", thickness: 0.2,
|
||||
}],
|
||||
columns: [],
|
||||
extrudedSolids: [],
|
||||
drawings2d: [],
|
||||
context: [],
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user