Prof is a Go benchmark profiling tool that automates performance analysis by wrapping Go's built-in benchmarking and pprof tools.
Prof solves three core problems:
- Automates profiling: Runs Go benchmarks with multiple profile types (CPU, memory, mutex, block)
- Organizes data: Creates structured directory hierarchies for profiling outputs
- Tracks performance: Compares benchmark runs to detect regressions and improvements
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ CLI Layer │───▶│ Engine Layer │───▶│ Parser Layer │
│ (User Input) │ │ (Business Logic)│ │ (Data Processing)│
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Internal │ │ Configuration │ │ File System │
│ (Utilities) │ │ (JSON Config) │ │ (Output Org) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
Minimal main function that delegates to CLI:
func main() {
if err := cli.Execute(); err != nil {
os.Exit(1)
}
}Framework: Cobra CLI
Commands:
auto- Automated benchmark execution with profilingmanual- Process existing profile filestrack- Compare performance between runssetup- Generate configuration templatestui- Text-based user interface
- Creates organized directory structures
- Executes
go test -benchwith profiling flags - Manages profile file organization
- Converts binary profiles to text format
- Generates PNG visualizations
- Applies function filtering
- Compares benchmark runs
- Detects performance changes
- Generates detailed reports
Converts pprof text output into structured data:
type LineObj struct {
FnName string
Flat float64
FlatPercentage float64
SumPercentage float64
Cum float64
CumPercentage float64
}JSON-based function filtering:
{
"function_collection_filter": {
"BenchmarkName": {
"include_prefixes": ["github.com/myorg/myproject"],
"ignore_functions": ["init", "TestMain"]
}
}
}Shared parameter structures for component communication.
File system operations and shared constants.
User → CLI → Benchmark Engine → Collector → Parser → Output Files
User → CLI → Tracker → Parser → Comparison → Report
bench/
├── {tag}/ # Run identifier
│ ├── bin/ # Binary profiles
│ ├── text/ # Text reports
│ ├── cpu_functions/ # Function-level data
│ └── memory_functions/
include_prefixes: Restrict to specific packagesignore_functions: Skip specific functions (supports wildcards)- Global filters: Apply to all benchmarks using
*key
- Integration Tests: End-to-end workflow testing
- Unit Tests: Component-specific testing
- Blackbox Tests: CLI validation and output verification
- CLI command validation
- Benchmark execution
- Profile parsing accuracy
- Error handling scenarios
- Cobra: CLI framework
- Go Toolchain: Built-in profiling tools
- Survey: Interactive prompts
Layered dependency structure with clear boundaries between components.
- Single Responsibility: Each package has one clear purpose
- Interface Segregation: Well-defined component interfaces
- Configuration Over Code: Behavior controlled through config files
- Comprehensive Error Handling: Descriptive errors and graceful degradation