Files
healer-man/scripts/playtest-wow-visual-performance.cjs
2026-10-06 22:25:34 -04:00

57 lines
3.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { chromium } = require('C:/Users/phenom/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright');
const fs = require('node:fs');
const path = require('node:path');
// Bounded before/after asset comparison; excludes actors, gameplay and physics.
(async () => {
const output = path.resolve('artifacts/playtest/wow-environment-quality/shadowfang-performance');
fs.mkdirSync(output, { recursive: true });
const stages = process.argv.slice(2).length ? process.argv.slice(2) : ['before-shadowfang', 'repacked-shadowfang', 'selective-shadowfang'];
if (stages.some((stage) => !['before-shadowfang', 'repacked-shadowfang', 'selective-shadowfang'].includes(stage))) throw new Error('Unknown Shadowfang review stage');
const resultsFile = path.join(output, 'results.json');
const results = process.argv.slice(2).length && fs.existsSync(resultsFile)
? JSON.parse(fs.readFileSync(resultsFile, 'utf8')).results.filter((entry) => !stages.includes(entry.stage)) : [];
const browser = await chromium.launch({ channel: 'msedge', headless: true });
try {
for (const stage of stages) {
const context = await browser.newContext({ viewport: { width: 1280, height: 800 } });
const page = await context.newPage();
const errors = [];
page.on('pageerror', (error) => errors.push(error.message));
try {
await page.goto(`http://127.0.0.1:4208/scripts/dungeon-pipeline/environment-preview.html?dungeon=shadowfang-keep&stage=${stage}`, { waitUntil: 'domcontentloaded' });
await page.waitForFunction(() => window.wowEnvironmentReview?.ready, null, { timeout: 180_000 });
const viewpoints = await page.evaluate(() => window.wowEnvironmentReview.viewpoints);
const cases = [
{ view: 0, quality: 'standard' },
...[...new Set([0, Math.floor((viewpoints.length - 1) / 2), viewpoints.length - 1])].map((view) => ({ view, quality: 'high' })),
];
const samples = [];
for (const entry of cases) {
await page.evaluate(({ view, quality }) => {
window.wowEnvironmentReview.setQuality(quality);
window.wowEnvironmentReview.view(view);
}, entry);
await page.waitForTimeout(1000);
await page.evaluate(() => window.wowEnvironmentReview.resetFrameSample());
await page.waitForTimeout(3000);
const sample = await page.evaluate(() => {
const { textures, ...diagnostics } = window.wowEnvironmentReview.diagnostics();
return { ...window.wowEnvironmentReview.frameSample(), ...diagnostics, textureCount: textures.length };
});
samples.push({ ...entry, name: viewpoints[entry.view].name, ...sample });
await page.screenshot({ path: path.join(output, `${stage}-${entry.quality}-view-${entry.view}.png`) });
}
results.push({ stage, errors, samples });
console.log(JSON.stringify({ stage, errors, samples }));
} finally {
await context.close();
}
}
fs.writeFileSync(resultsFile, `${JSON.stringify({ scope: 'isolated Edge asset renderer at 1280×800; 3-second samples after 1-second settle; no actor, physics or mobile performance certification', results }, null, 2)}\n`);
if (results.some((entry) => entry.errors.length)) process.exitCode = 1;
} finally {
await browser.close();
}
})().catch((error) => { console.error(error); process.exitCode = 1; });