Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,4 @@ The harness tries to reduce these paths (example: lasso timing is end-to-end and
## License

MIT © [Matin Mahmood](https://www.linkedin.com/in/matin-mahmood/) (X: [@MatinMnM](https://twitter.com/MatinMnM))

45 changes: 23 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"devDependencies": {
"@types/node": "^20.10.0",
"puppeteer": "^24.34.0",
"puppeteer": "^24.35.0",
"tsx": "^4.7.0",
"typescript": "^5.3.0",
"vite": "^5.0.0"
Expand Down
36 changes: 36 additions & 0 deletions src/benchmarks/run-browser-accuracy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,28 @@ async function startDevServer(): Promise<{ proc: ChildProcess; url: string }> {
}

async function runAccuracy(page: Page): Promise<{ allPassed: boolean; summary: string; reports: any[] }> {
// Wait for VizBenchmark module to be loaded and available on window
// This is necessary because ES modules load asynchronously and networkidle0
// doesn't guarantee module execution is complete
try {
await page.waitForFunction(
() => typeof (window as any).VizBenchmark !== 'undefined' &&
typeof (window as any).VizBenchmark.runAccuracyBenchmarks === 'function',
{ timeout: 30000 } // Increased timeout to 30s for slower systems
);
} catch (err: any) {
// If wait times out, get more diagnostic info
const pageInfo = await page.evaluate(() => {
return {
vizBenchmarkExists: typeof (window as any).VizBenchmark !== 'undefined',
vizBenchmarkType: typeof (window as any).VizBenchmark,
runAccuracyBenchmarksExists: typeof (window as any).VizBenchmark?.runAccuracyBenchmarks !== 'undefined',
windowKeys: Object.keys(window).filter(k => k.includes('Viz') || k.includes('benchmark')),
};
});
throw new Error(`Failed to load VizBenchmark module: ${JSON.stringify(pageInfo)}\nOriginal error: ${err?.message || err}`);
}

return page.evaluate(async () => {
const canvas = document.getElementById('canvas') as HTMLCanvasElement | null;
if (!canvas) throw new Error('Canvas element not found');
Expand Down Expand Up @@ -185,6 +207,20 @@ async function main() {
});

const page = await browser.newPage();

// Capture console errors for debugging
page.on('console', msg => {
const type = msg.type();
if (type === 'error' || type === 'warn') {
console.log(`[Browser ${type}]:`, msg.text());
}
});

// Capture page errors
page.on('pageerror', (error) => {
console.error('[Page Error]:', error);
});

// tsx/esbuild may wrap serialized functions passed to page.evaluate() with
// __name(...) calls. Define a no-op __name helper in the page context.
try {
Expand Down
35 changes: 35 additions & 0 deletions src/benchmarks/run-browser-bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,28 @@ async function runBenchmarks(
page: Page,
config: BenchConfig
): Promise<BenchmarkReport> {
// Wait for VizBenchmark module to be loaded and available on window
// This is necessary because ES modules load asynchronously and networkidle0
// doesn't guarantee module execution is complete
try {
await page.waitForFunction(
() => typeof (window as any).VizBenchmark !== 'undefined' &&
typeof (window as any).VizBenchmark.runBenchmarks === 'function',
{ timeout: 30000 } // Increased timeout to 30s for slower systems
);
} catch (err: any) {
// If wait times out, get more diagnostic info
const pageInfo = await page.evaluate(() => {
return {
vizBenchmarkExists: typeof (window as any).VizBenchmark !== 'undefined',
vizBenchmarkType: typeof (window as any).VizBenchmark,
runBenchmarksExists: typeof (window as any).VizBenchmark?.runBenchmarks !== 'undefined',
windowKeys: Object.keys(window).filter(k => k.includes('Viz') || k.includes('benchmark')),
};
});
throw new Error(`Failed to load VizBenchmark module: ${JSON.stringify(pageInfo)}\nOriginal error: ${err?.message || err}`);
}

// Optionally override canvas CSS size before starting.
// Width defaults to responsive container width; height defaults to 400px in benchmark.html.
await page.evaluate((canvasCfg: { width?: number; height?: number }) => {
Expand Down Expand Up @@ -449,6 +471,19 @@ async function main() {

const page = await browser.newPage();

// Capture console errors for debugging
page.on('console', msg => {
const type = msg.type();
if (type === 'error' || type === 'warn') {
console.log(`[Browser ${type}]:`, msg.text());
}
});

// Capture page errors
page.on('pageerror', (error) => {
console.error('[Page Error]:', error);
});

// Some bundlers/transpilers (notably esbuild) may emit a `__name(fn, name)`
// helper when serializing functions. Puppeteer executes `page.evaluate`
// callbacks in the *page* context, where that helper is not defined.
Expand Down