11"use client" ;
22
33import { motion } from "framer-motion" ;
4- import { BarChart3 } from "lucide-react" ;
4+ import { BarChart3 , Loader2 } from "lucide-react" ;
55import {
66 Card ,
77 CardContent ,
@@ -10,9 +10,11 @@ import {
1010 CardTitle ,
1111} from "@/components/ui/card" ;
1212import { Progress } from "@/components/ui/progress" ;
13- import { benchmarks } from "@/data/metrics " ;
13+ import { useBenchmarks } from "@/hooks/useBenchmarks " ;
1414
1515export function BenchmarksCard ( ) {
16+ const { benchmarks, loading, error } = useBenchmarks ( ) ;
17+
1618 return (
1719 < motion . div
1820 initial = { { opacity : 0 , y : 20 } }
@@ -26,50 +28,67 @@ export function BenchmarksCard() {
2628 LLM Performance Benchmarks
2729 </ CardTitle >
2830 < CardDescription className = "text-amber-200/60" >
29- Comparative analysis of local models on my homelab
31+ { loading ? "Loading benchmarks..." : error ? "Unable to fetch benchmarks" : " Comparative analysis of local models on my homelab" }
3032 </ CardDescription >
3133 </ CardHeader >
3234 < CardContent >
33- < div className = "overflow-x-auto" >
34- < table className = "w-full" >
35- < thead >
36- < tr className = "border-b border-amber-800/30" >
37- < th className = "text-left py-3 px-4 text-amber-200" > Model</ th >
38- < th className = "text-left py-3 px-4 text-amber-200" > Speed</ th >
39- < th className = "text-left py-3 px-4 text-amber-200" > Quality</ th >
40- < th className = "text-left py-3 px-4 text-amber-200" > Memory</ th >
41- </ tr >
42- </ thead >
43- < tbody >
44- { benchmarks . map ( ( bench , index ) => (
45- < motion . tr
46- key = { bench . model }
47- initial = { { opacity : 0 , x : - 20 } }
48- animate = { { opacity : 1 , x : 0 } }
49- transition = { { delay : 0.1 * index } }
50- className = "border-b border-amber-800/20 hover:bg-amber-900/20 transition-colors"
51- >
52- < td className = "py-3 px-4 text-amber-100 font-medium" >
53- { bench . model }
54- </ td >
55- < td className = "py-3 px-4 text-amber-200/80" > { bench . speed } </ td >
56- < td className = "py-3 px-4" >
57- < div className = "flex items-center gap-2" >
58- < Progress
59- value = { bench . quality }
60- className = "h-2 w-20 bg-amber-950/50"
61- />
62- < span className = "text-amber-200/80 text-sm" >
63- { bench . quality } %
64- </ span >
65- </ div >
66- </ td >
67- < td className = "py-3 px-4 text-amber-200/80" > { bench . memory } </ td >
68- </ motion . tr >
69- ) ) }
70- </ tbody >
71- </ table >
72- </ div >
35+ { loading ? (
36+ < div className = "flex items-center justify-center py-8" >
37+ < Loader2 className = "w-6 h-6 text-amber-500 animate-spin" />
38+ </ div >
39+ ) : error ? (
40+ < div className = "flex flex-col items-center justify-center py-8 text-center" >
41+ < BarChart3 className = "w-8 h-8 text-amber-500/50 mb-2" />
42+ < p className = "text-amber-200/60 text-sm" > { error } </ p >
43+ < p className = "text-amber-300/40 text-xs mt-1" > Make sure the backend is running</ p >
44+ </ div >
45+ ) : benchmarks . length === 0 ? (
46+ < div className = "flex flex-col items-center justify-center py-8 text-center" >
47+ < BarChart3 className = "w-8 h-8 text-amber-500/50 mb-2" />
48+ < p className = "text-amber-200/60 text-sm" > No benchmarks available</ p >
49+ </ div >
50+ ) : (
51+ < div className = "overflow-x-auto" >
52+ < table className = "w-full" >
53+ < thead >
54+ < tr className = "border-b border-amber-800/30" >
55+ < th className = "text-left py-3 px-4 text-amber-200" > Model</ th >
56+ < th className = "text-left py-3 px-4 text-amber-200" > Speed</ th >
57+ < th className = "text-left py-3 px-4 text-amber-200" > Quality</ th >
58+ < th className = "text-left py-3 px-4 text-amber-200" > Memory</ th >
59+ </ tr >
60+ </ thead >
61+ < tbody >
62+ { benchmarks . map ( ( bench , index ) => (
63+ < motion . tr
64+ key = { bench . model }
65+ initial = { { opacity : 0 , x : - 20 } }
66+ animate = { { opacity : 1 , x : 0 } }
67+ transition = { { delay : 0.1 * index } }
68+ className = "border-b border-amber-800/20 hover:bg-amber-900/20 transition-colors"
69+ >
70+ < td className = "py-3 px-4 text-amber-100 font-medium" >
71+ { bench . model }
72+ </ td >
73+ < td className = "py-3 px-4 text-amber-200/80" > { bench . speed } </ td >
74+ < td className = "py-3 px-4" >
75+ < div className = "flex items-center gap-2" >
76+ < Progress
77+ value = { bench . quality }
78+ className = "h-2 w-20 bg-amber-950/50"
79+ />
80+ < span className = "text-amber-200/80 text-sm" >
81+ { bench . quality } %
82+ </ span >
83+ </ div >
84+ </ td >
85+ < td className = "py-3 px-4 text-amber-200/80" > { bench . memory } </ td >
86+ </ motion . tr >
87+ ) ) }
88+ </ tbody >
89+ </ table >
90+ </ div >
91+ ) }
7392 </ CardContent >
7493 </ Card >
7594 </ motion . div >
0 commit comments