perfprofile

package
v0.0.3 Latest Latest
Warning

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

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

Documentation

Overview

Package perfprofile analyzes timing data from task checkpoints and the cost ledger to identify execution bottlenecks across a plan run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderBottleneckTable

func RenderBottleneckTable(p *Profile, top int, w io.Writer)

RenderBottleneckTable writes a ranked bottleneck table to w. top limits the number of tasks shown (0 = show all).

func RenderHistogram

func RenderHistogram(p *Profile, w io.Writer)

RenderHistogram writes an ASCII histogram of task duration distribution to w.

Types

type Profile

type Profile struct {
	Tasks     []*TaskProfile
	Providers map[string]*ProviderProfile

	// Plan-level span
	PlanStartedAt   *time.Time
	PlanCompletedAt *time.Time
	// TotalWallSpan is latest CompletedAt minus earliest StartedAt across all tasks.
	TotalWallSpan time.Duration
	// SumTaskDurations is the arithmetic sum of every task's WallTime.
	SumTaskDurations time.Duration
	// ParallelEfficiency = SumTaskDurations / TotalWallSpan.
	// Values > 1.0 indicate parallelism was used. 1.0 means purely sequential.
	ParallelEfficiency float64

	// Task duration distribution
	MeanTaskDuration time.Duration
	P95TaskDuration  time.Duration
	MaxTaskDuration  time.Duration
	// Durations contains every non-zero task WallTime, sorted ascending (for histogram).
	Durations []time.Duration

	// MeanQueueDelay is the mean wait time tasks spend queued between executions.
	MeanQueueDelay time.Duration
	// TotalQueueDelay is the sum of all queue delays.
	TotalQueueDelay time.Duration
}

Profile is the complete performance analysis result.

func Build

func Build(workDir string, s *state.ProjectState) *Profile

Build constructs a Profile from project state and on-disk artifacts. workDir is the project root (the directory that contains .cloop/).

type ProviderProfile

type ProviderProfile struct {
	Provider string

	// TotalCalls is the number of cost-ledger entries attributed to this provider.
	TotalCalls int
	// Latencies are per-step elapsed-second deltas derived from checkpoint history.
	Latencies []float64

	MeanSec float64
	P95Sec  float64
	MaxSec  float64

	TotalInputTokens  int
	TotalOutputTokens int
	TotalCostUSD      float64
}

ProviderProfile aggregates latency and usage stats for one provider+model pair.

type TaskProfile

type TaskProfile struct {
	TaskID    int
	TaskTitle string
	Status    string

	WallTime    time.Duration
	StartedAt   *time.Time
	CompletedAt *time.Time
	// QueueDelay is the gap between the previous task completing and this one starting.
	QueueDelay time.Duration

	Provider string
	Model    string

	InputTokens  int
	OutputTokens int
	CostUSD      float64
}

TaskProfile holds performance data for a single task execution.

Jump to

Keyboard shortcuts

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