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:
- github.com/AlexsanderHamir/prof/internal/repofs — module root discovery and tag directory resets
- github.com/AlexsanderHamir/prof/internal/testpaths — test helpers for locating fixture assets under tests/assets
Keep feature orchestration in engine packages and compose them via [app.Services] at the CLI boundary.
Index ¶
- Constants
- func CleanOrCreateTag(dir string) error
- func CreateTemplate() error
- func FindGoModuleRoot() (string, error)
- func GetScanner(filePath string) (*bufio.Scanner, *os.File, error)
- func PrintConfiguration(benchArgs *BenchArgs, functionFilterPerBench map[string]FunctionFilter)
- type BenchArgs
- type CIConfig
- type CITrackingConfig
- type CollectionArgs
- type Config
- type FunctionFilter
- type LineFilterArgs
Constants ¶
const ( AUTOCMD = "auto" MANUALCMD = "manual" TrackAutoCMD = AUTOCMD TrackManualCMD = MANUALCMD )
CLI subcommand names for collect and track flows.
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.
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 ¶
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 ¶
FindGoModuleRoot forwards to repofs.FindGoModuleRoot.
func GetScanner ¶
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 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 ¶
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.
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. |