mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-05 13:10:24 +00:00
## Summary Add subgraph workflow performance tests to track style recalculations and layout thrashing for nested subgraph workflows. ## Changes - **What**: Add 3 new perf test cases (`subgraph-idle`, `subgraph-mouse-sweep`, `subgraph-dom-widget-clipping`) that mirror the existing default workflow tests but load the `subgraphs/nested-subgraph` workflow. The existing perfReporter pipeline automatically picks up the new measurements. ## Review Focus The new tests are structurally identical to the existing 3 default workflow tests — only the workflow loaded and measurement names differ. No CI or config changes needed. Fixes https://www.notion.so/comfy-org/Implement-Add-subgraph-workflow-round-in-performance-testing-process-3156d73d365081d094efdee58215e15b ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9306-test-add-subgraph-workflow-round-to-performance-tests-3156d73d36508133b85cc53a748bc75f) by [Unito](https://www.unito.io)
133 lines
4.3 KiB
TypeScript
133 lines
4.3 KiB
TypeScript
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
|
|
import { recordMeasurement } from '../helpers/perfReporter'
|
|
|
|
test.describe('Performance', { tag: ['@perf'] }, () => {
|
|
test('canvas idle style recalculations', async ({ comfyPage }) => {
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
await comfyPage.perf.startMeasuring()
|
|
|
|
// Let the canvas idle for 2 seconds — no user interaction.
|
|
// Measures baseline style recalcs from reactive state + render loop.
|
|
for (let i = 0; i < 120; i++) {
|
|
await comfyPage.nextFrame()
|
|
}
|
|
|
|
const m = await comfyPage.perf.stopMeasuring('canvas-idle')
|
|
recordMeasurement(m)
|
|
console.log(
|
|
`Canvas idle: ${m.styleRecalcs} style recalcs, ${m.layouts} layouts`
|
|
)
|
|
})
|
|
|
|
test('canvas mouse interaction style recalculations', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
await comfyPage.perf.startMeasuring()
|
|
|
|
const canvas = comfyPage.canvas
|
|
const box = await canvas.boundingBox()
|
|
if (!box) throw new Error('Canvas bounding box not available')
|
|
|
|
// Sweep mouse across the canvas — crosses nodes, empty space, slots
|
|
for (let i = 0; i < 100; i++) {
|
|
await comfyPage.page.mouse.move(
|
|
box.x + (box.width * i) / 100,
|
|
box.y + (box.height * (i % 3)) / 3
|
|
)
|
|
}
|
|
|
|
const m = await comfyPage.perf.stopMeasuring('canvas-mouse-sweep')
|
|
recordMeasurement(m)
|
|
console.log(
|
|
`Mouse sweep: ${m.styleRecalcs} style recalcs, ${m.layouts} layouts`
|
|
)
|
|
})
|
|
|
|
test('DOM widget clipping during node selection', async ({ comfyPage }) => {
|
|
// Load default workflow which has DOM widgets (text inputs, combos)
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
await comfyPage.perf.startMeasuring()
|
|
|
|
// Select and deselect nodes rapidly to trigger clipping recalculation
|
|
const canvas = comfyPage.canvas
|
|
const box = await canvas.boundingBox()
|
|
if (!box) throw new Error('Canvas bounding box not available')
|
|
|
|
for (let i = 0; i < 20; i++) {
|
|
// Click on canvas area (nodes occupy various positions)
|
|
await comfyPage.page.mouse.click(
|
|
box.x + box.width / 3 + (i % 5) * 30,
|
|
box.y + box.height / 3 + (i % 4) * 30
|
|
)
|
|
await comfyPage.nextFrame()
|
|
}
|
|
|
|
const m = await comfyPage.perf.stopMeasuring('dom-widget-clipping')
|
|
recordMeasurement(m)
|
|
console.log(`Clipping: ${m.layouts} forced layouts`)
|
|
})
|
|
|
|
test('subgraph idle style recalculations', async ({ comfyPage }) => {
|
|
await comfyPage.workflow.loadWorkflow('subgraphs/nested-subgraph')
|
|
await comfyPage.perf.startMeasuring()
|
|
|
|
for (let i = 0; i < 120; i++) {
|
|
await comfyPage.nextFrame()
|
|
}
|
|
|
|
const m = await comfyPage.perf.stopMeasuring('subgraph-idle')
|
|
recordMeasurement(m)
|
|
console.log(
|
|
`Subgraph idle: ${m.styleRecalcs} style recalcs, ${m.layouts} layouts`
|
|
)
|
|
})
|
|
|
|
test('subgraph mouse interaction style recalculations', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('subgraphs/nested-subgraph')
|
|
await comfyPage.perf.startMeasuring()
|
|
|
|
const canvas = comfyPage.canvas
|
|
const box = await canvas.boundingBox()
|
|
if (!box) throw new Error('Canvas bounding box not available')
|
|
|
|
for (let i = 0; i < 100; i++) {
|
|
await comfyPage.page.mouse.move(
|
|
box.x + (box.width * i) / 100,
|
|
box.y + (box.height * (i % 3)) / 3
|
|
)
|
|
}
|
|
|
|
const m = await comfyPage.perf.stopMeasuring('subgraph-mouse-sweep')
|
|
recordMeasurement(m)
|
|
console.log(
|
|
`Subgraph mouse sweep: ${m.styleRecalcs} style recalcs, ${m.layouts} layouts`
|
|
)
|
|
})
|
|
|
|
test('subgraph DOM widget clipping during node selection', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('subgraphs/nested-subgraph')
|
|
await comfyPage.perf.startMeasuring()
|
|
|
|
const canvas = comfyPage.canvas
|
|
const box = await canvas.boundingBox()
|
|
if (!box) throw new Error('Canvas bounding box not available')
|
|
|
|
for (let i = 0; i < 20; i++) {
|
|
await comfyPage.page.mouse.click(
|
|
box.x + box.width / 3 + (i % 5) * 30,
|
|
box.y + box.height / 3 + (i % 4) * 30
|
|
)
|
|
await comfyPage.nextFrame()
|
|
}
|
|
|
|
const m = await comfyPage.perf.stopMeasuring('subgraph-dom-widget-clipping')
|
|
recordMeasurement(m)
|
|
console.log(`Subgraph clipping: ${m.layouts} forced layouts`)
|
|
})
|
|
})
|