This directory contains several scripts for analyzing pre-commit hook performance and identifying bottlenecks.
Purpose: Fast comparison between different execution methods
Best for: Quick checks and basic performance monitoring
What it does:
- Compares global
lintfunction vs local pre-commit - Tests pre-commit in commit context vs direct execution
- Measures shell hook performance directly
- Provides simple timing comparisons
Usage:
./quick-profile.shSample output:
⚡ Quick Pre-commit Performance Comparison
Lint function (global config): ✅ Success: 0.837s
Local pre-commit (repo config): ✅ Success: 0.555s
Pre-commit in commit context: ✅ Success: 0.712s
Shell hook directly: ✅ Success: 0.371s
Purpose: Comprehensive performance breakdown with multiple test runs
Best for: Detailed analysis and consistent measurements
What it does:
- Runs each test 3 times and calculates averages
- Measures individual tool performance (shellcheck, shfmt)
- Analyzes environment setup overhead
- Compares global vs local config loading
- Tests commit simulation scenarios
Usage:
./detailed-profile.shKey metrics provided:
- Pre-commit environment initialization time
- Individual tool execution times
- Config loading differences
- Statistical averages across multiple runs
Purpose: Direct side-by-side comparison of different approaches
Best for: Understanding the performance impact of each layer
What it does:
- Tests direct tool usage (shellcheck + shfmt)
- Compares shell hook script execution
- Measures pre-commit framework overhead
- Simulates actual commit process
- Shows cumulative overhead at each layer
Usage:
./compare-approaches.shDemonstrates:
- Raw tool performance vs framework overhead
- Step-by-step performance degradation
- Real-world commit simulation timing
Purpose: Detailed analysis report of profiling findings
Best for: Understanding results and optimization recommendations
Contains:
- Performance metrics summary table
- Bottleneck analysis breakdown
- Root cause identification
- Optimization recommendations
- Visual performance comparison charts
Use quick-profile.sh to check if performance has changed after configuration updates or system changes.
Use detailed-profile.sh when you need precise measurements or want to track performance over time.
Use compare-approaches.sh to understand exactly where time is being spent and evaluate alternative approaches.
Reference performance-analysis.md for the complete analysis and recommendations.
- Direct tools: 0.04-0.10s (shellcheck + shfmt combined)
- Shell hook script: 0.08-0.16s (tools + file management)
- Pre-commit runs: 0.5-0.6s (tools + framework overhead)
- Commit context: 0.6-0.8s (tools + framework + git integration)
The pre-commit framework has an inherent ~400-500ms initialization cost. This is normal and provides:
- Consistent tool versions across environments
- Dependency management
- Output formatting and collection
- Git integration features
- Hook orchestration and error handling
Consider investigating if you see:
- Sudden increases in timing (>50% slower than baseline)
- Individual tools taking >0.1s consistently
- Framework overhead >1s regularly
- Significant variance between runs (>100ms difference)
- Run all scripts to establish current baseline
- Compare with expected ranges above
- Check system resources (CPU, memory, disk I/O)
- Review recent changes to pre-commit config or system
- Test with minimal config to isolate problematic hooks
All scripts require:
bash(GNU Bash 5.x+)python3(for timing calculations)git(for repository operations)pre-commit(installed and configured)- Access to the configured shell linting tools (
shellcheck,shfmt)
- Scripts create temporary test files that are automatically cleaned up
- All timing uses Python's
time.time()for consistent measurements - Scripts are safe to run repeatedly and won't modify your actual code files
- Performance will vary based on system load and hardware specifications