bench

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package bench provides side-by-side provider benchmarking for cloop. It runs the same prompt against multiple providers concurrently and produces a comparison report with latency, token counts, cost estimates, and optional AI-rated quality scores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatMarkdownTable

func FormatMarkdownTable(r *Report) string

FormatMarkdownTable formats the report as a markdown table.

func SaveReport

func SaveReport(workDir string, r *Report) (string, error)

SaveReport writes the markdown report to .cloop/bench-results/<timestamp>.md. Returns the file path written.

Types

type ProviderResult

type ProviderResult struct {
	ProviderName string
	Model        string
	// Averaged across runs.
	AvgLatencyMS    float64
	MinLatencyMS    float64
	MaxLatencyMS    float64
	AvgInputTokens  float64
	AvgOutputTokens float64
	TotalCostUSD    float64
	// QualityScore is 1-10 as judged by the JudgeProvider. 0 means not rated.
	QualityScore float64
	// LastResponse is the last successful response (used for quality scoring).
	LastResponse string
	// Error is set when the provider failed on all runs.
	Error string
	// SuccessfulRuns counts how many runs succeeded.
	SuccessfulRuns int
}

ProviderResult holds aggregated results for a single provider.

type Report

type Report struct {
	Prompt    string
	Runs      int
	Timestamp time.Time
	Results   []*ProviderResult
}

Report is the result of a full benchmark session.

func Run

func Run(ctx context.Context, cfg RunConfig, providerBuilders map[string]provider.Provider) (*Report, error)

Run executes the benchmark and returns a Report. providerBuilders maps provider name → a built Provider instance.

type RunConfig

type RunConfig struct {
	// Prompt is the text sent to all providers.
	Prompt string
	// Providers is the list of provider names to benchmark.
	Providers []string
	// Models maps provider name → model override (empty = use provider default).
	Models map[string]string
	// Runs is the number of times each provider is called (results are averaged).
	Runs int
	// JudgeProvider is the provider used to rate response quality (empty = skip).
	JudgeProvider string
	// Timeout per individual completion call.
	Timeout time.Duration
}

RunConfig holds the configuration for a benchmark run.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL