import { useEffect, useRef, useState } from 'react' import { IconCpu, IconServer, IconRobot, IconTemperature, IconDatabase, IconChartBar } from '@tabler/icons-react' import StageRail from './StageRail' import CoreGrid from './CoreGrid' import Sparkline from './Sparkline' import LiveReadout from './LiveReadout' import ResultsSoFar from './ResultsSoFar' import type { BenchmarkRunHook } from '~/hooks/useBenchmarkRun' import type { BenchmarkStatus } from '../../../types/benchmark' function formatElapsed(ms: number): string { const s = Math.floor(ms / 1000) return `${Math.floor(s / 60)}:${(s % 60).toString().padStart(2, '0')}` } function StageHero({ run }: { run: BenchmarkRunHook }) { const status = run.status const heroCard = 'bg-desert-white rounded-lg p-6 border border-desert-stone-light h-full min-h-[240px] flex flex-col' const title = 'text-sm font-semibold text-desert-green uppercase tracking-wide mb-4 flex items-center gap-2' if (status === 'running_ai') { return (
AI Inference
) } if (status === 'running_disk_read' || status === 'running_disk_write') { const isRead = status === 'running_disk_read' // Prefer the authoritative in-test sysbench throughput once it's flowing; // fall back to the coarse host-proxy disk numbers until then. const hasInTest = run.diskMibs !== null return (
{isRead ? 'Disk Read' : 'Disk Write'}
) } if (status === 'calculating_score') { return (
Compiling Report
Calculating your NOMAD Score...
) } if (status === 'detecting_hardware' || status === 'starting' || status === null) { return (
Identifying Hardware
Detecting your system...
) } // CPU + memory stages: the core grid is the centrepiece. return (
{status === 'running_memory' ? 'Memory Throughput' : 'CPU Load'}
{status === 'running_cpu' && run.cpuEventsPerSec !== null && (
)}
) } /** Always-on host vitals, so something is moving between and during stages. */ function VitalsStrip({ run }: { run: BenchmarkRunHook }) { const card = 'bg-desert-white rounded-lg p-4 border border-desert-stone-light' return (
CPU Load
{run.tempC !== null && (
Temperature
)}
Disk
) } export default function BenchmarkRunView({ run }: { run: BenchmarkRunHook }) { // Elapsed clock, driven locally so it ticks even between telemetry frames. const startedAt = useRef(Date.now()) const [, force] = useState(0) useEffect(() => { const id = setInterval(() => force((n) => n + 1), 1000) return () => clearInterval(id) }, []) const activeStatus: BenchmarkStatus | null = run.status return (
) }