import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { BenchmarkTable } from "@/components/BenchmarkTable"; import { mirrors } from "@/config/mirrors"; import { benchmarkAllMirrors } from "@/utils/benchmark"; import { BenchmarkResult } from "@/types/benchmark"; import { toast } from "sonner"; import { Activity, Zap } from "lucide-react"; const Index = () => { const [did, setDid] = useState(""); const [loading, setLoading] = useState(false); const [results, setResults] = useState([]); const handleBenchmark = async () => { if (!did.trim()) { toast.error("Please enter a DID"); return; } setLoading(true); setResults([]); try { const benchmarkResults = await benchmarkAllMirrors(mirrors, did.trim()); setResults(benchmarkResults); const successCount = benchmarkResults.filter(r => r.status === "success").length; toast.success(`Benchmark complete! ${successCount}/${benchmarkResults.length} mirrors responded`); } catch (error) { toast.error("Failed to run benchmark"); console.error(error); } finally { setLoading(false); } }; const handleKeyPress = (e: React.KeyboardEvent) => { if (e.key === "Enter" && !loading) { handleBenchmark(); } }; return (
{/* Header */}

PLC Mirror Benchmark

Test and compare response times across different PLC.directory mirrors

{/* Input Section */}
setDid(e.target.value)} onKeyPress={handleKeyPress} className="flex-1 font-mono" disabled={loading} />
Testing {mirrors.length} mirrors with 3 attempts each
{/* Results Section */} {(results.length > 0 || loading) && (

Results

{loading ? (

Benchmarking mirrors...

) : ( )}
)} {/* Info Section */} {results.length === 0 && !loading && (

How to use:

  1. Enter an ATProto DID (e.g., did:plc:z72i7hdynmk6r22z27h6tvur)
  2. Click "Run Benchmark" or press Enter
  3. View response times and status for each mirror

Mirrors can be configured in src/config/mirrors.ts

)}
); }; export default Index;