-
-
{{ title }}
-
+
+
+ {{ title }}
+
+
{{ description }}
diff --git a/src/renderer/src/components/ui/FilterButton.vue b/src/renderer/src/components/ui/FilterButton.vue
new file mode 100644
index 000000000..873b908a7
--- /dev/null
+++ b/src/renderer/src/components/ui/FilterButton.vue
@@ -0,0 +1,27 @@
+
+
+
+
+
diff --git a/src/renderer/src/composables/usePerformanceTestRun.ts b/src/renderer/src/composables/usePerformanceTestRun.ts
new file mode 100644
index 000000000..35a5fb82b
--- /dev/null
+++ b/src/renderer/src/composables/usePerformanceTestRun.ts
@@ -0,0 +1,300 @@
+import { computed, onUnmounted, ref, shallowRef } from 'vue'
+import { useSessionStore } from '../stores/sessionStore'
+import { emitTelemetryAction } from '../lib/telemetry'
+import type { ActionResult, RunPerformanceTestWorkflowResult } from '../types/ipc'
+import { performanceTestSessionKey } from '../../../shared/performanceTestSession'
+
+export interface PerformanceTestRunRequest {
+ readonly installationId: string
+ readonly buildName: string
+ readonly workflowPath: string
+ readonly workflowName: string
+ readonly telemetryWorkflowName: string
+ readonly warmupRuns: number
+ readonly measuredRuns: number
+}
+
+export type PerformanceTestStage = 'idle' | 'starting' | 'running' | 'finishing' | 'stopping'
+
+interface RunTelemetry {
+ readonly installationId: string
+ readonly workflowName: string
+ readonly warmupRuns: number
+ readonly measuredRuns: number
+ readonly startedAtMs: number
+}
+
+type Translate = (key: string, values?: Record
) => string
+
+function secondsToMilliseconds(seconds: number | null | undefined): number | null {
+ return seconds == null ? null : seconds * 1000
+}
+
+function errorMessage(error: unknown, fallback: string): string {
+ return (error as Error | undefined)?.message || fallback
+}
+
+function emitCompleted(
+ telemetry: RunTelemetry,
+ submission: RunPerformanceTestWorkflowResult
+): void {
+ const summary = submission.resultsSummary
+ const statistics = submission.statistics
+ const hardware = submission.hardware
+ emitTelemetryAction('comfy.desktop.performance_test.completed', {
+ installation_id: telemetry.installationId,
+ workflow_name: telemetry.workflowName,
+ warmup_runs: telemetry.warmupRuns,
+ measured_runs: telemetry.measuredRuns,
+ successful_runs:
+ summary?.measuredJobCount ??
+ statistics?.measuredJobCount ??
+ Math.max(0, submission.submitted - (submission.failedRuns ?? 0)),
+ failed_runs: summary?.failedRunCount ?? submission.failedRuns ?? 0,
+ duration_ms: performance.now() - telemetry.startedAtMs,
+ fastest_run_duration_ms: secondsToMilliseconds(
+ summary?.fastestJobDurationSeconds ?? statistics?.fastest.durationSeconds
+ ),
+ average_run_duration_ms: secondsToMilliseconds(
+ summary?.averageJobDurationSeconds ?? statistics?.averageDurationSeconds
+ ),
+ median_run_duration_ms: secondsToMilliseconds(
+ summary?.medianJobDurationSeconds ?? statistics?.medianDurationSeconds
+ ),
+ slowest_run_duration_ms: secondsToMilliseconds(
+ summary?.slowestJobDurationSeconds ?? statistics?.slowest.durationSeconds
+ ),
+ deviceType: hardware?.deviceType ?? null,
+ deviceIndex: hardware?.deviceIndex ?? null,
+ deviceName: hardware?.deviceName ?? null,
+ backend: hardware?.backend ?? null,
+ devicesDeviceType: hardware?.devices.map((device) => device.deviceType) ?? [],
+ devicesDeviceIndex: hardware?.devices.map((device) => device.deviceIndex) ?? [],
+ devicesDeviceName: hardware?.devices.map((device) => device.deviceName) ?? [],
+ devicesBackend: hardware?.devices.map((device) => device.backend) ?? [],
+ vramMb: hardware?.vramMb ?? null,
+ ramMb: hardware?.ramMb ?? null,
+ pytorchVersion: hardware?.pytorchVersion ?? null,
+ xformersVersion: hardware?.xformersVersion ?? null,
+ cudaDeviceSet: hardware?.cudaDeviceSet ?? null
+ })
+}
+
+export function usePerformanceTestRun(t: Translate) {
+ const sessionStore = useSessionStore()
+ const isActive = ref(false)
+ const phase = ref<'starting' | 'running' | 'finishing'>('starting')
+ const isStopping = ref(false)
+ const buildInstallationId = ref(null)
+ const request = shallowRef(null)
+ const result = shallowRef(null)
+ const failure = ref(null)
+ const logSessionId = ref(null)
+ const progressSessionId = ref(null)
+ const completedRuns = ref(0)
+ const totalRuns = ref(0)
+ let activeLaunch: Promise | null = null
+ let activeTelemetry: RunTelemetry | null = null
+ let runToken = 0
+
+ const stage = computed(() => {
+ if (isStopping.value) return 'stopping'
+ return isActive.value ? phase.value : 'idle'
+ })
+ const isBusy = computed(() => stage.value !== 'idle')
+ const ownsBuild = computed(() => isBusy.value || buildInstallationId.value !== null)
+ const canStop = computed(() => Boolean(buildInstallationId.value && !isStopping.value))
+ const logs = computed(() =>
+ logSessionId.value ? (sessionStore.getSession(logSessionId.value)?.output ?? '') : ''
+ )
+
+ const unsubscribeProgress = window.api.onPerformanceTestProgress((progress) => {
+ if (progress.sessionId !== progressSessionId.value) return
+ completedRuns.value = progress.completedRuns
+ totalRuns.value = progress.totalRuns
+ })
+ onUnmounted(unsubscribeProgress)
+
+ function canStart(installationId: string): boolean {
+ return !isBusy.value && !sessionStore.isLaunching(performanceTestSessionKey(installationId))
+ }
+
+ async function submit(
+ run: PerformanceTestRunRequest,
+ sessionId: string,
+ token: number,
+ telemetry: RunTelemetry
+ ): Promise {
+ sessionStore.appendOutput(
+ sessionId,
+ `\n${t('performanceTest.submittingRuns', {
+ count: run.measuredRuns,
+ warmupCount: run.warmupRuns
+ })}\n`
+ )
+ let submission: RunPerformanceTestWorkflowResult | null = null
+ let outcome: string
+ try {
+ submission = await window.api.runPerformanceTestWorkflow(
+ sessionId,
+ run.workflowPath,
+ run.measuredRuns,
+ run.warmupRuns
+ )
+ outcome = submission.ok
+ ? t('performanceTest.completedRuns', {
+ count: submission.submitted,
+ failed: submission.failedRuns,
+ path: submission.resultPath
+ })
+ : submission.message || t('performanceTest.submitFailed')
+ } catch (error) {
+ outcome = errorMessage(error, t('performanceTest.submitFailed'))
+ }
+ if (token === runToken) {
+ if (submission?.ok) {
+ result.value = submission
+ if (activeTelemetry === telemetry) {
+ activeTelemetry = null
+ emitCompleted(telemetry, submission)
+ }
+ } else {
+ failure.value = outcome
+ }
+ }
+ sessionStore.appendOutput(sessionId, `${outcome}\n`)
+ }
+
+ async function saveLogs(sessionId: string, workflowPath: string): Promise {
+ const logs = sessionStore.getSession(sessionId)?.output
+ if (logs === undefined) return
+ try {
+ const saved = await window.api.savePerformanceTestLogs(workflowPath, logs)
+ if (!saved.ok) console.error('Failed to save performance test logs:', saved.message)
+ } catch (error) {
+ console.error('Failed to save performance test logs:', error)
+ }
+ }
+
+ async function start(run: PerformanceTestRunRequest): Promise {
+ if (!canStart(run.installationId)) return
+ const sessionId = performanceTestSessionKey(run.installationId)
+ const token = ++runToken
+ const telemetry: RunTelemetry = {
+ installationId: run.installationId,
+ workflowName: run.telemetryWorkflowName,
+ warmupRuns: run.warmupRuns,
+ measuredRuns: run.measuredRuns,
+ startedAtMs: performance.now()
+ }
+ activeTelemetry = telemetry
+ emitTelemetryAction('comfy.desktop.performance_test.started', {
+ installation_id: run.installationId,
+ workflow_name: telemetry.workflowName,
+ warmup_runs: run.warmupRuns,
+ measured_runs: run.measuredRuns,
+ total_runs: run.warmupRuns + run.measuredRuns
+ })
+ isActive.value = true
+ phase.value = 'starting'
+ request.value = run
+ result.value = null
+ failure.value = null
+ progressSessionId.value = sessionId
+ completedRuns.value = 0
+ totalRuns.value = run.warmupRuns + run.measuredRuns
+ try {
+ if (sessionStore.isRunning(sessionId)) await window.api.stopComfyUI(sessionId)
+ logSessionId.value = sessionId
+ buildInstallationId.value = run.installationId
+ sessionStore.startSession(sessionId)
+ activeLaunch = window.api.runAction(run.installationId, 'launch', {
+ launchModeOverride: 'console',
+ autoPortOnConflict: true,
+ sessionIdOverride: sessionId
+ })
+ const launched = await activeLaunch
+ activeLaunch = null
+ if (token !== runToken) return
+ if (!launched.ok) {
+ buildInstallationId.value = null
+ if (!launched.cancelled) {
+ failure.value = launched.message || t('performanceTest.launchFailed')
+ sessionStore.appendOutput(sessionId, failure.value)
+ }
+ return
+ }
+ phase.value = 'running'
+ await submit(run, sessionId, token, telemetry)
+ if (token !== runToken) return
+ phase.value = 'finishing'
+ await stop()
+ } catch (error) {
+ const message = errorMessage(error, t('performanceTest.launchFailed'))
+ sessionStore.appendOutput(sessionId, message)
+ if (token === runToken) failure.value = message
+ buildInstallationId.value = null
+ } finally {
+ await saveLogs(sessionId, run.workflowPath)
+ activeLaunch = null
+ if (activeTelemetry === telemetry) activeTelemetry = null
+ if (!result.value && !failure.value) request.value = null
+ progressSessionId.value = null
+ isActive.value = false
+ }
+ }
+
+ async function stop(): Promise {
+ const installationId = buildInstallationId.value
+ if (!installationId || !canStop.value) return
+ const sessionId = performanceTestSessionKey(installationId)
+ runToken += 1
+ isStopping.value = true
+ try {
+ await window.api.cancelOperation(sessionId)
+ if (activeLaunch) await activeLaunch.catch(() => undefined)
+ await window.api.stopComfyUI(sessionId)
+ if (buildInstallationId.value === installationId) buildInstallationId.value = null
+ } catch (error) {
+ sessionStore.appendOutput(
+ sessionId,
+ `\n${errorMessage(error, t('performanceTest.stopFailed'))}\n`
+ )
+ } finally {
+ isStopping.value = false
+ }
+ }
+
+ async function stopFromUser(): Promise {
+ const telemetry = activeTelemetry
+ if (telemetry) {
+ activeTelemetry = null
+ emitTelemetryAction('comfy.desktop.performance_test.stopped', {
+ installation_id: telemetry.installationId,
+ workflow_name: telemetry.workflowName,
+ warmup_runs: telemetry.warmupRuns,
+ measured_runs: telemetry.measuredRuns,
+ completed_runs: completedRuns.value,
+ total_runs: telemetry.warmupRuns + telemetry.measuredRuns,
+ duration_ms: performance.now() - telemetry.startedAtMs
+ })
+ }
+ await stop()
+ }
+
+ return {
+ stage,
+ isBusy,
+ ownsBuild,
+ canStop,
+ request,
+ result,
+ failure,
+ logs,
+ completedRuns,
+ totalRuns,
+ canStart,
+ start,
+ stopFromUser
+ }
+}
diff --git a/src/renderer/src/composables/usePerformanceTestWorkflow.ts b/src/renderer/src/composables/usePerformanceTestWorkflow.ts
new file mode 100644
index 000000000..e26a9763d
--- /dev/null
+++ b/src/renderer/src/composables/usePerformanceTestWorkflow.ts
@@ -0,0 +1,122 @@
+import { computed, ref, type Ref, type ShallowRef } from 'vue'
+import type TemplatePickerStep from '../components/TemplatePickerStep.vue'
+import { fileName } from '../lib/performanceTestResults'
+import { usePerformanceTestExampleWorkflow } from './usePerformanceTestExampleWorkflow'
+
+export type PerformanceTestWorkflowSource = 'example' | 'api'
+
+interface PerformanceTestWorkflowContext {
+ picker: Readonly | null>>
+ selectedInstallationId: Ref
+ isSelectedInstallationInstalled: Readonly[>
+ isLocked: Readonly][>
+ t: (key: string) => string
+}
+
+export function usePerformanceTestWorkflow(context: PerformanceTestWorkflowContext) {
+ const { isLocked, t } = context
+ const filePath = ref(null)
+ const error = ref(null)
+ const isImporting = ref(false)
+ const isDeleting = ref(false)
+
+ const example = usePerformanceTestExampleWorkflow({
+ picker: context.picker,
+ selectedInstallationId: context.selectedInstallationId,
+ isSelectedInstallationInstalled: context.isSelectedInstallationInstalled,
+ workflowFilePath: filePath,
+ workflowError: error,
+ isWorkflowImporting: isImporting,
+ isWorkflowLocked: isLocked,
+ deleteWorkflow: remove,
+ t
+ })
+
+ const source = computed(() => {
+ if (example.pendingLabel.value) return 'example'
+ if (!filePath.value) return null
+ return example.displayName.value === null ? 'api' : 'example'
+ })
+ const label = computed(
+ () =>
+ example.pendingLabel.value ??
+ example.displayName.value ??
+ (filePath.value ? fileName(filePath.value) : '')
+ )
+ const telemetryName = computed(() =>
+ example.displayName.value === null || !filePath.value ? 'custom' : fileName(filePath.value)
+ )
+ const isReady = computed(() =>
+ Boolean(
+ filePath.value &&
+ !isImporting.value &&
+ !isDeleting.value &&
+ !example.download.value &&
+ !example.isForOtherInstallation.value
+ )
+ )
+
+ async function importFrom(sourcePath?: string): Promise {
+ if (isImporting.value || isDeleting.value || isLocked.value) return
+ isImporting.value = true
+ error.value = null
+ try {
+ const result = await window.api.importPerformanceTestWorkflow(sourcePath)
+ if (result.ok && result.filePath) {
+ example.release()
+ filePath.value = result.filePath
+ } else if (!result.canceled) {
+ error.value = result.message || t('performanceTest.importFailed')
+ }
+ } catch (cause) {
+ error.value = (cause as Error)?.message || t('performanceTest.importFailed')
+ } finally {
+ isImporting.value = false
+ }
+ }
+
+ async function importFile(file: File): Promise {
+ const sourcePath = window.api.getPathForFile(file)
+ if (sourcePath) await importFrom(sourcePath)
+ }
+
+ async function remove(): Promise {
+ const removing = filePath.value
+ if (!removing || isDeleting.value || isLocked.value) return
+ isDeleting.value = true
+ error.value = null
+ try {
+ const result = await window.api.deletePerformanceTestWorkflow(removing)
+ if (result.ok) {
+ if (filePath.value === removing) {
+ filePath.value = null
+ example.clearState()
+ }
+ if (result.status === 'preserved') {
+ error.value = result.message || t('performanceTest.deleteFailed')
+ }
+ } else {
+ error.value = result.message || t('performanceTest.deleteFailed')
+ }
+ } catch (cause) {
+ error.value = (cause as Error)?.message || t('performanceTest.deleteFailed')
+ } finally {
+ isDeleting.value = false
+ }
+ }
+
+ return {
+ filePath,
+ error,
+ isImporting,
+ isDeleting,
+ source,
+ label,
+ telemetryName,
+ isReady,
+ importFrom,
+ importFile,
+ remove,
+ example
+ }
+}
diff --git a/src/renderer/src/lib/performanceTestResults.ts b/src/renderer/src/lib/performanceTestResults.ts
new file mode 100644
index 000000000..97909e917
--- /dev/null
+++ b/src/renderer/src/lib/performanceTestResults.ts
@@ -0,0 +1,122 @@
+import type { PerformanceTestResultsSummary } from '../types/ipc'
+
+type SystemInfo = PerformanceTestResultsSummary['systemInfo']
+
+export const RUN_COUNT_LIMITS = {
+ warmup: { min: 0, max: 5, fallback: 1 },
+ measured: { min: 1, max: 100, fallback: 5 }
+} as const
+
+export type RunCountLimits = (typeof RUN_COUNT_LIMITS)[keyof typeof RUN_COUNT_LIMITS]
+
+export function clampRunCount(value: string | number, limits: RunCountLimits): number {
+ const raw = String(value).trim()
+ const parsed = raw === '' ? Number.NaN : Number(raw)
+ if (!Number.isFinite(parsed)) return limits.fallback
+ return Math.min(limits.max, Math.max(limits.min, Math.round(parsed)))
+}
+
+export function formatDuration(seconds: number): string {
+ return `${seconds.toFixed(3)} s`
+}
+
+export function formatMemory(megabytes: number): string {
+ return `${(megabytes / 1024).toFixed(1)} GB`
+}
+
+export function formatOperatingSystem(info: SystemInfo): string {
+ return (
+ [info.os_distro, info.os_release].filter(Boolean).join(' ') ||
+ `${info.platform} ${info.os_version}`
+ )
+}
+
+export const DURATION_KEYS = ['fastest', 'median', 'average', 'slowest'] as const
+export type DurationKey = (typeof DURATION_KEYS)[number]
+export type RunDurations = Record
+
+export interface DurationRow {
+ key: DurationKey
+ seconds: number
+ share: number
+ highlight: boolean
+}
+
+export function summaryDurations(summary: PerformanceTestResultsSummary): RunDurations | null {
+ const fastest = summary.fastestJobDurationSeconds
+ const median = summary.medianJobDurationSeconds
+ const average = summary.averageJobDurationSeconds
+ const slowest = summary.slowestJobDurationSeconds
+ if (fastest === null || median === null || average === null || slowest === null) return null
+ return { fastest, median, average, slowest }
+}
+
+export function durationRows(durations: RunDurations): DurationRow[] {
+ const longest = Math.max(...DURATION_KEYS.map((key) => durations[key]))
+ return DURATION_KEYS.map((key) => ({
+ key,
+ seconds: durations[key],
+ share: longest > 0 ? durations[key] / longest : 0,
+ highlight: key === 'median'
+ }))
+}
+
+export type SystemFactKey =
+ | 'device'
+ | 'vram'
+ | 'ram'
+ | 'pytorchVersion'
+ | 'xformersVersion'
+ | 'cpu'
+ | 'cpuCores'
+ | 'operatingSystem'
+ | 'architecture'
+
+export interface SystemFact {
+ key: SystemFactKey
+ value: string
+}
+
+export function systemFacts(
+ hardware: PerformanceTestResultsSummary['hardware'] | undefined,
+ systemInfo: SystemInfo | undefined
+): SystemFact[] {
+ const facts: SystemFact[] = []
+ const add = (key: SystemFactKey, value: string | null | undefined): void => {
+ if (value) facts.push({ key, value })
+ }
+ if (hardware) {
+ add('device', hardware.devices.flatMap((device) => device.deviceName ?? []).join(', '))
+ if (hardware.vramMb != null) add('vram', formatMemory(hardware.vramMb))
+ if (hardware.ramMb != null) add('ram', formatMemory(hardware.ramMb))
+ add('pytorchVersion', hardware.pytorchVersion)
+ add('xformersVersion', hardware.xformersVersion)
+ }
+ if (systemInfo) {
+ add('cpu', systemInfo.cpu_model)
+ add('cpuCores', String(systemInfo.cpu_cores))
+ add('operatingSystem', formatOperatingSystem(systemInfo))
+ add('architecture', systemInfo.arch)
+ }
+ return facts
+}
+
+export function lastNonEmptyLine(text: string): string {
+ let end = text.length
+ while (end > 0) {
+ const start = text.lastIndexOf('\n', end - 1)
+ const line = text.slice(start + 1, end).trim()
+ if (line) return line
+ end = Math.max(start, 0)
+ }
+ return ''
+}
+
+export function fileName(filePath: string): string {
+ return filePath.split(/[\\/]/).pop() ?? ''
+}
+
+export function parentFolder(filePath: string): string | null {
+ const separatorIndex = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\'))
+ return separatorIndex > 0 ? filePath.slice(0, separatorIndex) : null
+}
diff --git a/src/renderer/src/lib/performanceTestResultsSvg.test.ts b/src/renderer/src/lib/performanceTestResultsSvg.test.ts
index c22bd1431..e5bb916ba 100644
--- a/src/renderer/src/lib/performanceTestResultsSvg.test.ts
+++ b/src/renderer/src/lib/performanceTestResultsSvg.test.ts
@@ -1,19 +1,23 @@
import { describe, expect, it } from 'vitest'
-import { createPerformanceTestResultsSvg } from './performanceTestResultsSvg'
+import { createPerformanceTestResultsSvg, estimateTextWidth } from './performanceTestResultsSvg'
describe('createPerformanceTestResultsSvg', () => {
it('renders the result metrics and escapes system values as valid XML', () => {
const svg = createPerformanceTestResultsSvg({
title: 'Performance Test: cat-workflow.json',
- aggregateTitle: 'Run duration aggregates',
+ aggregateTitle: 'Run duration',
systemInformationTitle: 'System information',
testDateTime: 'Sep 11, 2026, 12:34 PM',
- metrics: [
- { label: 'Measured runs', value: '5' },
- { label: 'Fastest run', value: '1.250 s', durationSeconds: 1.25 }
+ headline: { label: 'Median run · 5 measured · 0 failed', value: '1.500 s' },
+ durations: [
+ { label: 'Fastest run', value: '1.250 s', durationSeconds: 1.25 },
+ { label: 'Median run', value: '1.500 s', durationSeconds: 1.5, highlight: true },
+ { label: 'Slowest run', value: '2.500 s', durationSeconds: 2.5 }
],
- hardware: [{ label: 'Compute device', value: 'GPU & efficient' }],
- system: [{ label: 'CPU', value: 'Example CPU' }]
+ system: [
+ { label: 'Compute device', value: 'GPU & efficient' },
+ { label: 'CPU', value: 'Example CPU' }
+ ]
})
expect(svg).toContain(']