/**
 * Speed benchmark harness — measures the latency impact of speedProfile
 * optimizations (1-h cache TTL + pre-warming) against the current baseline
 * (5-min cache TTL, no pre-warm).
 *
 * Uses a mock streaming provider that simulates realistic provider timing:
 *   - Cold prefill (cache miss): proportional to uncached input tokens
 *   - Warm prefill (cache hit): 10× faster (cache reads cost 0.1×)
 *   - Output streaming: at a configurable token rate
 *   - Cache TTL: configurable (5 min baseline vs 1 h optimized)
 *
 * No real API calls are made — the mock uses real `setTimeout` for prefill and
 * output-token latency (so wall-clock measurements are meaningful) but a
 * virtual clock for inter-turn delays (so multi-minute gaps are instant).
 *
 * Run via vitest:  npx vitest run src/core/speed-benchmark.test.ts
 * Or as a script:  npx tsx src/core/speed-benchmark.ts
 */
import { StreamResult, type StreamOptions } from "@kenkaiiii/gg-ai";
export interface MockTimingConfig {
    /** ms per uncached input token during prefill (cold start). */
    coldPrefillMsPerToken: number;
    /** ms per cached input token during prefill (cache hit). 10× faster. */
    warmPrefillMsPerToken: number;
    /** ms per output token (determines streaming rate). ~15ms = 66 tok/s. */
    outputMsPerToken: number;
    /** Cache TTL in ms. 5_000 = baseline (5 min), 3_600_000 = optimized (1 h). */
    cacheTtlMs: number;
    /** Fixed network overhead per request (TCP + TLS + auth). */
    networkOverheadMs: number;
    /** Default output tokens per turn if not specified by the workload. */
    defaultOutputTokens: number;
}
export declare const REALISTIC_TIMING: MockTimingConfig;
/**
 * A mock streaming provider that simulates LLM timing with cache semantics.
 * Registered as provider "benchmark-mock" so the real agent loop code path
 * is exercised end-to-end.
 */
export declare class MockBenchmarkProvider {
    private cache;
    private config;
    /** Virtual clock — lets the benchmark simulate multi-minute gaps between
     *  turns without actually sleeping. The cache TTL check uses this, not
     *  Date.now(). Only prefill/output latency uses real setTimeout. */
    private virtualNow;
    readonly stats: {
        cacheHits: number;
        cacheMisses: number;
        cacheWrites: number;
        cacheEvictions: number;
        totalPrefillMs: number;
        totalOutputMs: number;
        totalNetworkMs: number;
        turns: number;
    };
    constructor(config?: Partial<MockTimingConfig>);
    /** Update config (e.g., switch TTL for baseline vs optimized run). */
    setConfig(config: Partial<MockTimingConfig>): void;
    /** Advance the virtual clock (for cache TTL simulation without real sleeping). */
    advanceClock(ms: number): void;
    /** Clear all cache state and stats (between benchmark runs). */
    reset(): void;
    /** Number of entries currently in the mock cache. */
    getCacheSize(): number;
    /** Force a cache write (simulates pre-warming). */
    prewarm(cacheKey: string, tokenCount: number): void;
    stream(options: StreamOptions): StreamResult;
    private runStream;
    /** Compute a stable cache key from the system prompt + tool names. */
    private computeCacheKey;
}
export interface WorkloadTurn {
    /** User message content. */
    prompt: string;
    /** Delay before this turn (simulates user think time). Default: 0. */
    delayMs?: number;
    /** Override output tokens for this turn. */
    outputTokens?: number;
}
export interface Workload {
    name: string;
    /** System prompt (simulates a realistic coding-agent system prompt). */
    systemPrompt: string;
    /** Tool definitions (names only for the mock). */
    toolNames: string[];
    turns: WorkloadTurn[];
}
export interface TurnMetrics {
    turnNumber: number;
    promptPreview: string;
    delayBeforeTurnMs: number;
    ttftMs: number;
    cacheHit: boolean;
    inputTokens: number;
    outputTokens: number;
    wallClockMs: number;
}
export interface BenchmarkResult {
    name: string;
    config: MockTimingConfig;
    prewarmed: boolean;
    turns: TurnMetrics[];
    totalWallClockMs: number;
    totalTtftMs: number;
    cacheHits: number;
    cacheMisses: number;
    cacheHitRate: number;
}
/** Run a workload against the mock provider and collect per-turn metrics. */
export declare function runBenchmark(workload: Workload, config: MockTimingConfig, options?: {
    prewarm?: boolean;
    name?: string;
}): Promise<BenchmarkResult>;
export interface ComparisonResult {
    baseline: BenchmarkResult;
    optimized: BenchmarkResult;
    wallClockImprovement: number;
    ttftImprovement: number;
    cacheHitRateImprovement: number;
}
export declare function compareResults(baseline: BenchmarkResult, optimized: BenchmarkResult): ComparisonResult;
/** Format a benchmark result as a readable table. */
export declare function formatResultTable(result: BenchmarkResult): string;
/** Format a side-by-side comparison. */
export declare function formatComparison(comparison: ComparisonResult): string;
/** A realistic multi-turn coding workload with time gaps that expose the
 *  5-min vs 1-h TTL difference. */
export declare function createDefaultWorkload(): Workload;
/** Run baseline vs optimized and return the comparison. Uses scaled-down
 *  timing (10× faster than real) so the benchmark completes in seconds. */
export declare function runFullBenchmark(): Promise<ComparisonResult>;
//# sourceMappingURL=speed-benchmark.d.ts.map