[K4] S4 Import: Aufrufer auf den Kern umgestellt, TS-Umwandlung gelöscht
DXF/DWG/PDF (Import-Dialog, CLI), IFC (Meshes/Bauteile) und Meshes laufen über ProjectDocument.importDrawing/ importIfc/importMesh (Store commitImport, ein Undo-Schritt). Dialoge halten nur Puffer + Zusammenfassung (io/importSource.ts). Gelöscht: dxfToDrawings, pdfLineStyles, ifcElements, decodeImport/decodeIfc/decodeMesh, ifcToImportedMeshes, meshObjectsToImportedMeshes, pdfPageToImport, buildDrawings, planImportLayers, Store addDrawingLevel/importDrawings, Paritätstests. ensureContextCategories als Fassade über den Kern; CLI-PDF bekommt wie die App Linienstile für Strichmuster. Tests über importView.testutil (Leseansicht des Kerns).
This commit is contained in:
52 files changed
+880
-3010
No files matched your search
+13
-27
@@ -1,7 +1,7 @@
|
||||
// Misst den DXF-/DWG-Import (Rust-Format-Modul, `src/io/dxfParser.ts`) an einer ECHTEN Datei:
|
||||
// (1) Einzel-Pass, (2) für grosse ASCII-DXF die parallele Aufteilung (`split.rs`) über echte
|
||||
// `worker_threads` (Node-Äquivalent der Browser-Worker in `dxfParserAsync.ts`). Korrektheit:
|
||||
// Gesamtzahlen (Konturen/Punkte/Texte/Meshes) müssen zwischen beiden Läufen IDENTISCH sein.
|
||||
// Gesamtzahlen (Konturen/Texte/Meshes, Zusammenfassung des Kerns) müssen zwischen beiden Läufen IDENTISCH sein.
|
||||
//
|
||||
// Lauf: `node scripts/bench-dxf-parallel.mjs <pfad.dxf|pfad.dwg>` (vorher `npm run build:fileio`).
|
||||
|
||||
@@ -9,8 +9,9 @@ import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { Worker } from "node:worker_threads";
|
||||
import { initFileioSync } from "../src/engine/fileioWasm";
|
||||
import { decodeImport, importDrawingFlat } from "../src/io/dxfParser";
|
||||
import type { DxfImportResult } from "../src/io/dxfParser";
|
||||
import { initCoreSync } from "../src/engine/coreWasm";
|
||||
import { importDrawingFlat } from "../src/io/dxfParser";
|
||||
import { importSummary, packChunks, type ImportChunk, type ImportSummary } from "../src/io/importSource";
|
||||
|
||||
const path = process.argv[2];
|
||||
const workerPath = process.argv[3];
|
||||
@@ -21,16 +22,10 @@ if (!path || !workerPath) {
|
||||
const wasmPath = resolve("src/engine/pkgFileIo/fileio_bg.wasm");
|
||||
const CLOSER = new TextEncoder().encode("0\nENDSEC\n0\nEOF\n");
|
||||
|
||||
function countAll(res: DxfImportResult) {
|
||||
let contours = 0;
|
||||
let points = 0;
|
||||
for (const set of res.contours) {
|
||||
for (const c of set.contours) {
|
||||
contours++;
|
||||
points += c.pts.length;
|
||||
}
|
||||
}
|
||||
return { contours, points, texts: res.texts?.length ?? 0, meshes: res.meshes.length };
|
||||
/** Zahlen der Zusammenfassung (Kern liest die Stücke wie in der App). */
|
||||
function countAll(chunks: ImportChunk[]) {
|
||||
const s: ImportSummary = importSummary(packChunks(chunks));
|
||||
return { contours: s.contours, texts: s.texts, meshes: s.meshes, entities: s.diagnostics.total };
|
||||
}
|
||||
|
||||
console.log(`\nImport-Benchmark: ${path}\n`);
|
||||
@@ -38,6 +33,7 @@ const bytes = new Uint8Array(readFileSync(path));
|
||||
console.log(` Datei: ${(bytes.length / 1024 / 1024).toFixed(0)} MB\n`);
|
||||
const t00 = performance.now();
|
||||
const m = await initFileioSync(readFileSync(wasmPath));
|
||||
initCoreSync(readFileSync(resolve("src/engine/pkgCore/core_bg.wasm")));
|
||||
console.log(` Modul laden: ${(performance.now() - t00).toFixed(0).padStart(7)} ms`);
|
||||
|
||||
// Erster Lauf wärmt die WASM-Engine auf (Tier-up von Liftoff auf TurboFan) — gemessen wird beides.
|
||||
@@ -47,11 +43,10 @@ console.log(` Erster Lauf: ${(performance.now() - tw).toFixed(0).padStart(7)
|
||||
const t0 = performance.now();
|
||||
const flat = importDrawingFlat(bytes);
|
||||
const tRust = performance.now();
|
||||
const single = decodeImport(flat.geom, flat.strings);
|
||||
const singleCounts = countAll([flat]);
|
||||
const singleMs = performance.now() - t0;
|
||||
const singleCounts = countAll(single);
|
||||
console.log(
|
||||
` Einzel-Pass: ${singleMs.toFixed(0).padStart(7)} ms (Rust ${(tRust - t0).toFixed(0)} ms, Dekodieren ${(performance.now() - tRust).toFixed(0)} ms)`,
|
||||
` Einzel-Pass: ${singleMs.toFixed(0).padStart(7)} ms (Lesen ${(tRust - t0).toFixed(0)} ms, Kern-Zusammenfassung ${(t0 + singleMs - tRust).toFixed(0)} ms)`,
|
||||
singleCounts,
|
||||
);
|
||||
|
||||
@@ -92,25 +87,16 @@ const results = await Promise.all(
|
||||
}),
|
||||
),
|
||||
);
|
||||
const decoded = results.map((r, i) => decodeImport(r.geom, r.strings, `c${i}-`));
|
||||
const merged = countAll(results.map((r) => ({ geom: r.geom, strings: r.strings })));
|
||||
const parallelMs = performance.now() - t1;
|
||||
for (const [i, r] of results.entries()) {
|
||||
console.log(
|
||||
` Worker ${i}: Start→Modul ${(r.tGotInput - spawned[i]).toFixed(0)} ms, Rust ${(r.tParsed - r.tGotInput).toFixed(0)} ms`,
|
||||
);
|
||||
}
|
||||
const merged = decoded.reduce(
|
||||
(a, r) => {
|
||||
const c = countAll(r);
|
||||
return { contours: a.contours + c.contours, points: a.points + c.points, texts: a.texts + c.texts, meshes: a.meshes + c.meshes };
|
||||
},
|
||||
{ contours: 0, points: 0, texts: 0, meshes: 0 },
|
||||
);
|
||||
console.log(` Parallel (${chunks.length} Worker): ${(parallelMs + splitMs).toFixed(0).padStart(7)} ms inkl. Scan `, merged);
|
||||
const ok =
|
||||
merged.contours === singleCounts.contours &&
|
||||
merged.points === singleCounts.points &&
|
||||
merged.texts === singleCounts.texts;
|
||||
merged.contours === singleCounts.contours && merged.texts === singleCounts.texts && merged.meshes === singleCounts.meshes;
|
||||
console.log(`\n Korrektheit: ${ok ? "IDENTISCH ✓" : "ABWEICHUNG ✗"}`);
|
||||
console.log(` Speedup: ${(singleMs / (parallelMs + splitMs)).toFixed(2)}x\n`);
|
||||
if (!ok) process.exit(1);
|
||||
Reference in new issue
Block a user