diff --git a/demo/benchmark_large_house.mjs b/demo/benchmark_large_house.mjs index ed64754b..499ee584 100644 --- a/demo/benchmark_large_house.mjs +++ b/demo/benchmark_large_house.mjs @@ -5,6 +5,7 @@ import { dirname, resolve } from 'node:path'; import { launch } from './serve.mjs'; import { LARGE_HOUSE_COUNTS, makeLargeHouseFixture } from './fixtures/large-house.mjs'; import { assertFreshDemoBundle } from './bundle-freshness.mjs'; +import { ensureHarnessEditorRuntime } from './editor-runtime-compat.mjs'; import { summarizeLongTasks, summarizeTimings } from './performance/evaluate.mjs'; import { assertCardContract, LARGE_HOUSE_CARD_CONTRACT } from './performance/card-contract.mjs'; @@ -52,6 +53,9 @@ await page.addStyleTag({ await page.addScriptTag({ content: `window.__hpAssertCardContract = ${assertCardContract.toString()};`, }); +await page.addScriptTag({ + content: `window.__hpEnsureHarnessEditorRuntime = ${ensureHarnessEditorRuntime.toString()};`, +}); const chromium = await browser.version(); let buildFingerprint; try { @@ -187,6 +191,11 @@ try { card._onLabsSnapshot({ active: Object.freeze(['iso']), space: '' }); } card.hass = hassFor(fixture.states); + // launch() warms its own bootstrap card, but each measured sample creates + // a fresh card. Current lazy bundles therefore need their own controller + // construction; monolithic stable bundles remain immediate (#380). + if (!await window.__hpEnsureHarnessEditorRuntime(card)) + throw new Error('large-house editor runtime did not preload'); window.__hpAssertCardContract(card, cardContract); if (requiresIsometric && (typeof card._setProjection !== 'function' || !(card._isoGeometryCache instanceof Map))) { diff --git a/test/performance-contract.test.mjs b/test/performance-contract.test.mjs index 4f0f6634..c1b19a6b 100644 --- a/test/performance-contract.test.mjs +++ b/test/performance-contract.test.mjs @@ -37,6 +37,16 @@ test('large-house benchmark declares every private card member it consumes', () ); }); +test('every measured large-house card preloads its own lazy editor runtime (#380)', () => { + const source = readFileSync( + new URL('../demo/benchmark_large_house.mjs', import.meta.url), 'utf8', + ); + const create = source.indexOf("document.createElement('houseplan-card')"); + const preload = source.indexOf('await window.__hpEnsureHarnessEditorRuntime(card)', create); + const contract = source.indexOf('window.__hpAssertCardContract(card, cardContract)', create); + assert.ok(create >= 0 && preload > create && contract > preload); +}); + test('Glow benchmark declares every private card member it consumes', () => { const declared = new Set([ ...declaredMembers(GLOW_CARD_CONTRACT),