internal

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package internal holds shared configuration (Config, BenchArgs), path constants ([const.go]), config/template IO (PrintConfiguration, LoadFromFile), and thin wrappers around lower-level helpers.

Related packages:

Keep feature orchestration in engine packages and compose them via [app.Services] at the CLI boundary.

Index

Constants

View Source
const (
	AUTOCMD        = "auto"
	MANUALCMD      = "manual"
	TrackAutoCMD   = AUTOCMD
	TrackManualCMD = MANUALCMD
)

CLI subcommand names for collect and track flows.

View Source
const (
	InfoCollectionSuccess = "All benchmarks and profile processing completed successfully!"
	IMPROVEMENT           = "IMPROVEMENT"
	REGRESSION            = "REGRESSION"
	STABLE                = "STABLE"
)

Messages and labels for benchmark results and CI-style comparisons.

View Source
const (
	MainDirOutput      = "bench"
	ProfileTextDir     = "text"
	ToolDir            = "tools"
	ProfileBinDir      = "bin"
	PermDir            = 0o755
	PermFile           = 0o644
	FunctionsDirSuffix = "_functions"
	ToolsResultsSuffix = "_results.txt"
	TextExtension      = "txt"
	ConfigFilename     = "config_template.json"
	GlobalSign         = "*"
	ExpectedTestSuffix = ".test"
)

Output directory names and file layout constants for bench artifacts.

Variables

This section is empty.

Functions

func CleanOrCreateTag

func CleanOrCreateTag(dir string) error

CleanOrCreateTag wraps repofs.CleanOrCreateTag using PermDir.

func CreateTemplate

func CreateTemplate() error

CreateTemplate creates a template configuration file from the actual Config struct with pre-built examples.

func FindGoModuleRoot

func FindGoModuleRoot() (string, error)

FindGoModuleRoot forwards to repofs.FindGoModuleRoot.

func GetScanner

func GetScanner(filePath string) (*bufio.Scanner, *os.File, error)

GetScanner opens a profile file and returns a line scanner and the open file handle.

func PrintConfiguration

func PrintConfiguration(benchArgs *BenchArgs, functionFilterPerBench map[string]FunctionFilter)

PrintConfiguration logs parsed benchmark arguments and optional per-benchmark function filters.

Types

type BenchArgs

type BenchArgs struct {
	Benchmarks []string
	Profiles   []string
	Count      int
	Tag        string
}

BenchArgs holds arguments for the auto-benchmark command.

type CIConfig

type CIConfig struct {
	// Global CI/CD settings that apply to all tracking operations
	Global *CITrackingConfig `json:"global,omitempty"`

	// Benchmark-specific CI/CD settings
	Benchmarks map[string]CITrackingConfig `json:"benchmarks,omitempty"`
}

CIConfig holds CI/CD specific configuration for performance tracking

type CITrackingConfig

type CITrackingConfig struct {
	// Functions to ignore during performance comparison (reduces noise)
	// These functions won't cause CI/CD failures even if they regress
	IgnoreFunctions []string `json:"ignore_functions,omitempty"`

	// Function prefixes to ignore during performance comparison
	// Example: ["runtime.", "reflect."] ignores all runtime and reflect functions
	IgnorePrefixes []string `json:"ignore_prefixes,omitempty"`

	// Minimum change threshold for CI/CD failure
	// Only functions with changes >= this threshold will cause failures
	MinChangeThreshold float64 `json:"min_change_threshold,omitempty"`

	// Maximum acceptable regression percentage for CI/CD
	// Overrides command-line regression threshold if set
	MaxRegressionThreshold float64 `json:"max_regression_threshold,omitempty"`

	// Whether to fail on improvements (useful for detecting unexpected optimizations)
	FailOnImprovement bool `json:"fail_on_improvement,omitempty"`
}

CITrackingConfig defines CI/CD specific filtering for performance tracking

type CollectionArgs

type CollectionArgs struct {
	Tag             string
	Profiles        []string
	BenchmarkName   string
	BenchmarkConfig FunctionFilter
}

CollectionArgs describes one benchmark collection run.

type Config

type Config struct {
	FunctionFilter map[string]FunctionFilter `json:"function_collection_filter"`
	// CI/CD specific configuration for performance tracking
	CIConfig *CIConfig `json:"ci_config,omitempty"`
}

Config holds the main configuration for the prof tool.

func LoadFromFile

func LoadFromFile(filename string) (*Config, error)

LoadFromFile loads and validates config from a JSON file.

type FunctionFilter

type FunctionFilter struct {
	// Prefixes: only collect functions starting with these prefixes
	// Example: []string{"github.com/example/GenPool"}
	IncludePrefixes []string `json:"include_prefixes,omitempty"`

	// IgnoreFunctions ignores the function name after the last dot.
	// Example: "Get,Set" excludes pool.Get() and cache.Set()
	IgnoreFunctions []string `json:"ignore_functions,omitempty"`
}

FunctionFilter defines filters for a specific benchmark when collecting line-level data.

type LineFilterArgs

type LineFilterArgs struct {
	ProfileFilters    map[int]float64
	IgnoreFunctionSet map[string]struct{}
	IgnorePrefixSet   map[string]struct{}
}

LineFilterArgs holds profile line filters and ignore sets for collection.

Directories

Path Synopsis
Package app defines the CLI composition root (Services): inject interfaces to swap benchmark, collector, tracker, tools, or setup without changing cobra command wiring.
Package app defines the CLI composition root (Services): inject interfaces to swap benchmark, collector, tracker, tools, or setup without changing cobra command wiring.
Package repofs holds repository filesystem helpers: locating the Go module root and tag directories.
Package repofs holds repository filesystem helpers: locating the Go module root and tag directories.

Jump to

Keyboard shortcuts

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