package main

import "fmt"

// section: example
func main() {
	fmt.Println("This package contains benchmark tests.")
	fmt.Println("Run benchmarks with: go test -bench=.")
	fmt.Println()
	fmt.Println("Example commands:")
	fmt.Println("  go test -bench=. -benchmem")
	fmt.Println("  go test -bench=BenchmarkAppend -benchmem")
	fmt.Println("  go test -bench=. -benchtime=10s")
	fmt.Println()
	fmt.Println("Key findings from benchmarks:")
	fmt.Println()
	fmt.Println("1. Pre-allocation with make([]T, 0, capacity) is significantly faster")
	fmt.Println("   than growing a slice through repeated append operations.")
	fmt.Println()
	fmt.Println("2. Using make([]T, length) and direct indexing is fastest when you")
	fmt.Println("   know the final size, avoiding append overhead entirely.")
	fmt.Println()
	fmt.Println("3. As slice size increases, the performance impact of not pre-allocating")
	fmt.Println("   becomes more severe due to repeated memory reallocations.")
	fmt.Println()
	fmt.Println("4. For iteration, range loops are generally as fast or faster than")
	fmt.Println("   index-based loops and are more idiomatic Go.")
	fmt.Println()
	fmt.Println("Best practices:")
	fmt.Println("- Pre-allocate capacity when you know approximate final size")
	fmt.Println("- Use make([]T, length) when size is exactly known")
	fmt.Println("- Prefer range loops for readability without performance penalty")
}

// section: example
