stats

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregateActivityBuckets added in v0.3.0

func AggregateActivityBuckets(sessions []conv.Session) []conv.ActivityBucketRow

func FilterByTimeRange

func FilterByTimeRange(sessions []conv.SessionMeta, tr TimeRange) []conv.SessionMeta

func FormatNumber

func FormatNumber(n int) string

func FormatValue

func FormatValue(id string, value float64) string

FormatValue renders a performance metric value using the metric's display convention.

Types

type Activity

type Activity struct {
	ActiveDays    int
	TotalDays     int
	CurrentStreak int
	LongestStreak int
	DailySessions []DailyCount
	DailyMessages []DailyCount
	DailyTokens   []DailyCount
	Heatmap       [7][24]int
}

func ComputeActivity

func ComputeActivity(sessions []conv.SessionMeta, timeRange TimeRange) Activity

func ComputeActivityFromBuckets added in v0.3.0

func ComputeActivityFromBuckets(
	sessions []conv.SessionMeta,
	activityBuckets []conv.ActivityBucketRow,
	timeRange TimeRange,
) Activity

type ActivityBucketRow added in v0.3.0

type ActivityBucketRow = conv.ActivityBucketRow

type Cache added in v0.3.0

type Cache struct {
	TotalCacheRead  int
	TotalCacheWrite int
	TotalPrompt     int
	HitRate         float64
	WriteRate       float64
	MissRate        float64
	ReuseRatio      float64
	Main            CacheSegment
	Subagent        CacheSegment
	DailyHitRate    []DailyRate
	DailyReuseRatio []DailyRate
	DurationBuckets []CacheDurationBucket
}

func ComputeCache added in v0.3.0

func ComputeCache(sessions []conv.SessionMeta, timeRange TimeRange) Cache

type CacheDurationBucket added in v0.3.0

type CacheDurationBucket struct {
	Label      string
	HitRate    float64
	ReuseRatio float64
	Sessions   int
}

type CacheSegment added in v0.3.0

type CacheSegment struct {
	SessionCount int
	CacheRead    int
	CacheWrite   int
	Prompt       int
	HitRate      float64
	MissTokens   int
}

type DailyCount

type DailyCount struct {
	Date  time.Time
	Count int
}

type DailyRate added in v0.3.0

type DailyRate struct {
	Date        time.Time
	Rate        float64
	HasActivity bool
}

type HistogramBucket

type HistogramBucket struct {
	Label string
	Count int
}

type ModelTokens

type ModelTokens struct {
	Model  string
	Tokens int
}

type Overview

type Overview struct {
	SessionCount int
	MessageCount int
	Tokens       TokenTotals
	TokenTrend   TokenTrend
	ByModel      []ModelTokens
	ByProject    []ProjectTokens
	TopSessions  []SessionSummary
}

func ComputeOverview

func ComputeOverview(sessions []conv.SessionMeta) Overview

type Performance

type Performance struct {
	Scope       PerformanceScope
	Overall     PerformanceScore
	Outcome     PerformanceLane
	Discipline  PerformanceLane
	Efficiency  PerformanceLane
	Robustness  PerformanceLane
	Diagnostics []PerformanceDiagnostic
}

func ComputePerformance

func ComputePerformance(
	conversations []conv.Conversation,
	timeRange TimeRange,
	sequence []PerformanceSequenceSession,
) Performance

type PerformanceDiagnostic

type PerformanceDiagnostic struct {
	Group       string
	Label       string
	Value       string
	Detail      string
	Current     float64
	Baseline    float64
	HasBaseline bool
	Trend       TrendDirection
	Series      []PerformancePoint
}

type PerformanceLane

type PerformanceLane struct {
	Label    string
	Detail   string
	Score    int
	HasScore bool
	Trend    TrendDirection
	Metrics  []PerformanceMetric
}

type PerformanceMetric

type PerformanceMetric struct {
	ID             string
	Label          string
	Value          string
	Detail         string
	Question       string
	Formula        string
	Current        float64
	Baseline       float64
	DeltaText      string
	HasBaseline    bool
	Score          int
	ScoreWeight    float64
	HasScore       bool
	Trend          TrendDirection
	Status         PerformanceMetricStatus
	SampleCount    int
	HigherIsBetter bool
	Series         []PerformancePoint
}

type PerformanceMetricStatus

type PerformanceMetricStatus int
const (
	PerformanceMetricStatusNone PerformanceMetricStatus = iota
	PerformanceMetricStatusBetter
	PerformanceMetricStatusWorse
	PerformanceMetricStatusFlat
	PerformanceMetricStatusLowSample
)

type PerformancePoint

type PerformancePoint struct {
	Timestamp   time.Time
	Value       float64
	SampleCount int
}

type PerformanceScope

type PerformanceScope struct {
	SessionCount         int
	Providers            []string
	Models               []string
	PrimaryProvider      string
	PrimaryModel         string
	SingleProvider       bool
	SingleModel          bool
	SingleFamily         bool
	CurrentRange         TimeRange
	BaselineRange        TimeRange
	SequenceLoaded       bool
	SequenceSampleCount  int
	BaselineSessionCount int
}

type PerformanceScore

type PerformanceScore struct {
	Score    int
	HasScore bool
	Trend    TrendDirection
}

type PerformanceSequenceSession

type PerformanceSequenceSession = conv.PerformanceSequenceSession

func CollectPerformanceSequenceSessions

func CollectPerformanceSequenceSessions(sessions []conv.Session) []PerformanceSequenceSession

type PositionTokenMetrics

type PositionTokenMetrics struct {
	Position            int
	AveragePromptTokens float64
	AverageTurnTokens   float64
	SampleCount         int
}

func ComputeTurnTokenMetrics

func ComputeTurnTokenMetrics(sessions []conv.Session) []PositionTokenMetrics

func ComputeTurnTokenMetricsForRange

func ComputeTurnTokenMetricsForRange(
	sessions []SessionTurnMetrics,
	timeRange TimeRange,
) []PositionTokenMetrics

type ProjectTokens

type ProjectTokens struct {
	Project string
	Tokens  int
}

type SessionSummary

type SessionSummary struct {
	Project      string
	Slug         string
	SessionID    string
	FilePath     string
	Timestamp    time.Time
	MessageCount int
	Duration     time.Duration
	Tokens       int
}

type SessionToolMetrics

type SessionToolMetrics struct {
	Timestamp        time.Time
	ToolCounts       map[string]int
	ActionCounts     map[string]int
	ToolErrorCounts  map[string]int
	ToolRejectCounts map[string]int
}

func CollectSessionToolMetrics

func CollectSessionToolMetrics(sessions []conv.Session) []SessionToolMetrics

type SessionTurnMetrics

type SessionTurnMetrics = conv.SessionTurnMetrics

func CollectSessionTurnMetrics

func CollectSessionTurnMetrics(sessions []conv.Session) []SessionTurnMetrics

type Sessions

type Sessions struct {
	AverageDuration       time.Duration
	AverageMessages       float64
	UserMessageCount      int
	AssistantMessageCount int
	UserAssistantRatio    float64
	AbandonedCount        int
	AbandonedRate         float64
	DurationHistogram     []HistogramBucket
	MessageHistogram      []HistogramBucket
	ClaudeTurnMetrics     []PositionTokenMetrics
}

func ComputeSessions

func ComputeSessions(sessions []conv.SessionMeta) Sessions

type Snapshot

type Snapshot struct {
	Overview    Overview
	Activity    Activity
	Sessions    Sessions
	Tools       Tools
	Cache       Cache
	Performance Performance
}

func ComputeSnapshot

func ComputeSnapshot(
	conversations []conv.Conversation,
	timeRange TimeRange,
	sequence []PerformanceSequenceSession,
) Snapshot

func ComputeSnapshotWithPrecomputed added in v0.3.0

func ComputeSnapshotWithPrecomputed(
	conversations []conv.Conversation,
	timeRange TimeRange,
	sequence []conv.PerformanceSequenceSession,
	turnMetrics []conv.SessionTurnMetrics,
	dailyTokens []conv.ActivityBucketRow,
) Snapshot

type TimeRange

type TimeRange struct {
	Start time.Time
	End   time.Time
}

type TokenTotals

type TokenTotals struct {
	Total      int
	Input      int
	Output     int
	CacheRead  int
	CacheWrite int
}

type TokenTrend

type TokenTrend struct {
	Direction     TrendDirection
	PercentChange int
}

func ComputeTokenTrend

func ComputeTokenTrend(sessions []conv.SessionMeta, timeRange TimeRange) TokenTrend

func ComputeTokenTrendFromBuckets added in v0.3.0

func ComputeTokenTrendFromBuckets(
	activityBuckets []conv.ActivityBucketRow,
	timeRange TimeRange,
) TokenTrend

type ToolCategoryShare

type ToolCategoryShare struct {
	Read  float64
	Write float64
	Bash  float64
}

type ToolRateStat

type ToolRateStat struct {
	Name  string
	Count int
	Total int
	Rate  float64
}

func ComputeToolErrorRates

func ComputeToolErrorRates(sessions []conv.SessionMeta) []ToolRateStat

func ComputeToolRejectRates

func ComputeToolRejectRates(sessions []SessionToolMetrics, timeRange TimeRange) []ToolRateStat

type ToolStat

type ToolStat struct {
	Name  string
	Count int
}

type Tools

type Tools struct {
	TotalCalls             int
	AverageCallsPerSession float64
	ErrorRate              float64
	RejectionRate          float64
	ReadWriteBashShare     ToolCategoryShare
	TopTools               []ToolStat
	CallsPerSession        []HistogramBucket
	ToolErrorRates         []ToolRateStat
	ToolRejectRates        []ToolRateStat
}

func ComputeTools

func ComputeTools(sessions []conv.SessionMeta) Tools

func ComputeToolsFromSessionMetrics

func ComputeToolsFromSessionMetrics(sessions []SessionToolMetrics, timeRange TimeRange) Tools

type TrendDirection

type TrendDirection int
const (
	TrendDirectionNone TrendDirection = iota
	TrendDirectionUp
	TrendDirectionDown
	TrendDirectionFlat
)

type TurnTokens

type TurnTokens = conv.TurnTokens

Jump to

Keyboard shortcuts

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