mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-18 03:20:07 +00:00
## Summary Use `group_by_job_time` for exports spanning multiple jobs while keeping single-job exports on `preserve`, and add regression coverage for the new naming-strategy behavior. ## Changes - **What**: updated the asset export payload and request typing for the new naming-strategy values, added unit coverage for single-job vs multi-job export requests, added `@cloud` sidebar browser coverage for export payloads, and adjusted the cloud Playwright setup helpers so setup API calls can hit the backend directly and Firebase auth is seeded on the app origin - **Breaking**: none - **Dependencies**: none ## Review Focus Please sanity-check the cloud Playwright harness changes in `ComfyPage` and `CloudAuthHelper`, plus the single-job vs multi-job export naming-strategy assertions in the new browser tests. ## Screenshots (if applicable) N/A ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-11610-Fix-naming-strategy-for-multi-job-asset-exports-34c6d73d365081a68a88ea38d897578f) by [Unito](https://www.unito.io) --------- Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: Alexander Brown <drjkl@comfy.org>
90 lines
2.7 KiB
TypeScript
90 lines
2.7 KiB
TypeScript
import { mkdirSync, readdirSync, readFileSync, writeFileSync } from 'fs'
|
|
import { join } from 'path'
|
|
|
|
import type { PerfMeasurement } from '@e2e/fixtures/helpers/PerformanceHelper'
|
|
|
|
export interface PerfReport {
|
|
timestamp: string
|
|
gitSha: string
|
|
branch: string
|
|
measurements: PerfMeasurement[]
|
|
}
|
|
|
|
const TEMP_DIR = join('test-results', 'perf-temp')
|
|
|
|
type MeasurementField = keyof PerfMeasurement
|
|
|
|
const FIELD_FORMATTERS: Record<string, (m: PerfMeasurement) => string> = {
|
|
styleRecalcs: (m) => `${m.styleRecalcs} recalcs`,
|
|
layouts: (m) => `${m.layouts} layouts`,
|
|
taskDurationMs: (m) => `${m.taskDurationMs.toFixed(1)}ms task`,
|
|
layoutDurationMs: (m) => `${m.layoutDurationMs.toFixed(1)}ms layout`,
|
|
frameDurationMs: (m) => `${m.frameDurationMs.toFixed(1)}ms/frame`,
|
|
totalBlockingTimeMs: (m) => `TBT=${m.totalBlockingTimeMs.toFixed(0)}ms`,
|
|
durationMs: (m) => `${m.durationMs.toFixed(0)}ms total`,
|
|
heapDeltaBytes: (m) => `heap Δ${(m.heapDeltaBytes / 1024).toFixed(0)}KB`,
|
|
domNodes: (m) => `DOM Δ${m.domNodes}`,
|
|
heapUsedBytes: (m) => `heap ${(m.heapUsedBytes / 1024 / 1024).toFixed(1)}MB`
|
|
}
|
|
|
|
/**
|
|
* Log a perf measurement to the console in a consistent format.
|
|
* Fields are formatted automatically based on their type.
|
|
*/
|
|
export function logMeasurement(
|
|
label: string,
|
|
m: PerfMeasurement,
|
|
fields: MeasurementField[]
|
|
) {
|
|
const parts = fields.map((f) => {
|
|
const formatter = FIELD_FORMATTERS[f]
|
|
if (formatter) return formatter(m)
|
|
return `${f}=${m[f]}`
|
|
})
|
|
// oxlint-disable-next-line no-console -- perf reporter intentionally logs to stdout
|
|
console.log(`${label}: ${parts.join(', ')}`)
|
|
}
|
|
|
|
export function recordMeasurement(m: PerfMeasurement) {
|
|
mkdirSync(TEMP_DIR, { recursive: true })
|
|
const filename = `${m.name}-${Date.now()}.json`
|
|
const { allFrameDurationsMs: _, ...serializable } = m
|
|
writeFileSync(join(TEMP_DIR, filename), JSON.stringify(serializable))
|
|
}
|
|
|
|
export function writePerfReport(
|
|
gitSha = process.env.GITHUB_SHA ?? 'local',
|
|
branch = process.env.GITHUB_HEAD_REF ?? 'local'
|
|
) {
|
|
let entries
|
|
try {
|
|
entries = readdirSync('test-results', { withFileTypes: true })
|
|
} catch {
|
|
return
|
|
}
|
|
if (!entries.length) return
|
|
|
|
let tempFiles: string[]
|
|
try {
|
|
tempFiles = readdirSync(TEMP_DIR).filter((f) => f.endsWith('.json'))
|
|
} catch {
|
|
return
|
|
}
|
|
if (tempFiles.length === 0) return
|
|
|
|
const measurements: PerfMeasurement[] = tempFiles.map((f) =>
|
|
JSON.parse(readFileSync(join(TEMP_DIR, f), 'utf-8'))
|
|
)
|
|
|
|
const report: PerfReport = {
|
|
timestamp: new Date().toISOString(),
|
|
gitSha,
|
|
branch,
|
|
measurements
|
|
}
|
|
writeFileSync(
|
|
join('test-results', 'perf-metrics.json'),
|
|
JSON.stringify(report, null, 2)
|
|
)
|
|
}
|