Skip to content

Commit

Permalink
split working time and export time
Browse files Browse the repository at this point in the history
  • Loading branch information
elalish committed Dec 4, 2024
1 parent a13ceab commit 346a0a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 0 additions & 6 deletions bindings/wasm/examples/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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() {
Expand Down
10 changes: 10 additions & 0 deletions bindings/wasm/examples/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}

0 comments on commit 346a0a5

Please sign in to comment.