mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
## Summary Enhances the CI performance report with explicit FPS metrics, percentile frame times, and milestone target thresholds. ### Changes **PerformanceHelper** (data collection): - `measureFrameDurations()` now returns individual frame durations instead of just the average, enabling percentile computation - Computes `p95FrameDurationMs` from sorted frame durations - Strips `allFrameDurationsMs` from serialized JSON to avoid bloating artifacts **perf-report.ts** (report rendering): - **Headline summary** at top of report with key metrics per test scenario - **FPS display**: derives avg FPS and P5 FPS from frame duration metrics - **Target thresholds**: shows P5 FPS ≥ 52 target with ✅/❌ pass/fail indicator - **p95 frame time**: added as a tracked metric in the comparison table - Metrics reordered to show frame time/FPS first (what people look for) ### Target From the Nodes 2.0 Perf milestone: **P5 ≥ 52 FPS** on 245-node workflow (equivalent to P95 frame time ≤ 19.2ms). ### Example headline output ``` > **vue-large-graph-pan**: 60 avg FPS · 58 P5 FPS ✅ (target: ≥52) · 12ms TBT · 45.2 MB heap > **canvas-zoom-sweep**: 45 avg FPS · 38 P5 FPS ❌ (target: ≥52) · 85ms TBT · 52.1 MB heap ``` Follow-up to #10477 (merged). ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10516-perf-add-FPS-p95-frame-time-and-target-thresholds-to-CI-perf-report-32e6d73d365081a2a2a6ceae7d6e9be5) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action <action@github.com>
83 lines
2.5 KiB
TypeScript
83 lines
2.5 KiB
TypeScript
import { mkdirSync, readdirSync, readFileSync, writeFileSync } from 'fs'
|
|
import { join } from 'path'
|
|
|
|
import type { PerfMeasurement } from '../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]}`
|
|
})
|
|
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'
|
|
) {
|
|
if (!readdirSync('test-results', { withFileTypes: true }).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)
|
|
)
|
|
}
|