From 346a0a5789167386c08613fd92303df766ecda4f Mon Sep 17 00:00:00 2001 From: Emmett Lalish Date: Tue, 3 Dec 2024 22:43:53 -0800 Subject: [PATCH] split working time and export time --- bindings/wasm/examples/editor.js | 6 ------ bindings/wasm/examples/worker.ts | 10 ++++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bindings/wasm/examples/editor.js b/bindings/wasm/examples/editor.js index a4be7395b..bb311c04a 100644 --- a/bindings/wasm/examples/editor.js +++ b/bindings/wasm/examples/editor.js @@ -434,16 +434,11 @@ function disableCancel() { runButton.classList.remove('red', 'cancel'); } -let t0 = performance.now(); - function finishRun() { disableCancel(); - const t1 = performance.now(); const log = consoleElement.textContent; // Remove "Running..." consoleElement.textContent = log.substring(log.indexOf('\n') + 1); - console.log( - `Took ${(Math.round((t1 - t0) / 10) / 100).toLocaleString()} seconds`); } const output = { @@ -501,7 +496,6 @@ async function run() { console.log('Running...'); const output = await tsWorker.getEmitOutput(editor.getModel().uri.toString()); manifoldWorker.postMessage(output.outputFiles[0].text); - t0 = performance.now(); } function cancel() { diff --git a/bindings/wasm/examples/worker.ts b/bindings/wasm/examples/worker.ts index 8669dc0a4..ace0e8524 100644 --- a/bindings/wasm/examples/worker.ts +++ b/bindings/wasm/examples/worker.ts @@ -186,6 +186,7 @@ let timesAccessor: Accessor; let weightsAccessor: Accessor; let weightsSampler: AnimationSampler; let hasAnimation: boolean; +let t0 = 0; export function cleanup() { for (const obj of memoryRegistry) { @@ -736,6 +737,10 @@ async function exportModels(defaults: GlobalDefaults, manifold?: Manifold) { to3mf.items.push({objectID: `${object2globalID.get(manifold)}`}); } + const t1 = performance.now(); + console.log(`Manifold took ${ + (Math.round((t1 - t0) / 10) / 100).toLocaleString()} seconds`); + if (!hasAnimation) { timesAccessor.dispose(); weightsAccessor.dispose(); @@ -759,6 +764,10 @@ async function exportModels(defaults: GlobalDefaults, manifold?: Manifold) { [zipFile], {type: 'application/vnd.ms-package.3dmanufacturing-3dmodel+xml'}); + const t2 = performance.now(); + console.log(`Exporting GLB & 3MF took ${ + (Math.round((t2 - t1) / 10) / 100).toLocaleString()} seconds`); + return ({ glbURL: URL.createObjectURL(blobGLB), threeMFURL: URL.createObjectURL(blob3MF) @@ -786,6 +795,7 @@ function evaluateCADToManifold(code: string) { } export async function evaluateCADToModel(code: string) { + t0 = performance.now(); const {globalDefaults, manifold} = evaluateCADToManifold(code); return await exportModels(globalDefaults, manifold); }