Command Palette

Search for a command to run...

AI Elements / Devtools/AI Latency Meter

AI Latency Meter

Response time visualization with TTFB and total duration display, color-coded performance indicators, animated progress bar, and compact/expanded variants.

Open in v0Open in
GPT-4o Response Time
0ms1s3s5s+
TTFB

245ms

Total

1.85s

Claude
920ms
GPT-4
2.1s
Gemini
450ms

Overview

A compound component for visualizing AI response latency with color-coded performance indicators. Shows time to first byte (TTFB) and total duration with animated progress bars. Supports compact (inline badge) and expanded (full bar chart) variants.

Installation

bunx shadcn@latest add @elements/latency-meter

Usage

import {
  LatencyMeter,
  LatencyMeterBar,
  LatencyMeterStats,
} from "@/components/elements/ai-elements/devtools/latency-meter";

export function LatencyMeterExample() {
  return (
    <LatencyMeter ttfb={450} total={2100} status="complete">
      <LatencyMeterBar />
      <LatencyMeterStats />
    </LatencyMeter>
  );
}

Props

LatencyMeter

PropTypeDefaultDescription
ttfbnumber-Time to first byte in milliseconds
totalnumber-Total request duration in milliseconds
status"loading" | "complete""complete"Current request status
variant"compact" | "expanded""expanded"Display variant

Performance Levels

// Color coding based on total duration
const levels = {
  fast: total < 1000,     // Green
  moderate: total < 3000, // Yellow
  slow: total >= 3000,    // Red
};

Features

  • Visual progress bar showing TTFB vs streaming time
  • Color-coded performance indicators (fast/moderate/slow)
  • Compact inline badge variant for tight spaces
  • Expanded bar chart variant with detailed breakdown
  • Loading animation during active requests
  • TTFB and total duration display