internal

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AUTOCMD        = "auto"
	MANUALCMD      = "manual"
	TrackAutoCMD   = AUTOCMD
	TrackManualCMD = MANUALCMD
)
View Source
const (
	InfoCollectionSuccess = "All benchmarks and profile processing completed successfully!"
	IMPROVEMENT           = "IMPROVEMENT"
	REGRESSION            = "REGRESSION"
	STABLE                = "STABLE"
)
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"
)

Variables

This section is empty.

Functions

func CleanOrCreateTag

func CleanOrCreateTag(dir string) error

CleanOrCreateTag cleans the tag directory if it exists, or creates one.

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 searches upwards from the current working directory for a directory containing a go.mod file and returns its absolute path. If none is found, an error is returned.

func GetScanner

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

func PrintConfiguration

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

Types

type BenchArgs

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

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
}

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"`
}

FunctionCollectionFilter defines filters for a specific benchmark, the filters are used when deciding which functions to collect code line level information for.

type LineFilterArgs

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

Jump to

Keyboard shortcuts

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