@@ -19,6 +19,9 @@ Empirical complexity regression checker: run a target function across input size
1919| ** 🧮 Time Complexity** | Fits to 9 classes: O(1), O(log n), O(√n), O(n), O(n log n), O(n²), O(n³), O(2ⁿ), O(n!) |
2020| ** 📐 Space Complexity** | Classifies memory usage to complexity classes |
2121| ** 📏 Polynomial Fitting** | Detect O(n^k) for arbitrary k (e.g., O(n^2.34)) |
22+ | ** 🔀 Git Commit Tracking** | Track complexity across commits, binary search for regression |
23+ | ** ⚠️ Instability Detection** | Detect noisy/unreliable benchmark results |
24+ | ** 🏷️ Badge Generation** | SVG badges for READMEs (color-coded by complexity) |
2225| ** 📊 Statistical Significance** | P-values to validate complexity classification |
2326| ** 🔄 Regression Detection** | CLI: ` bigocheck regression --baseline file.json ` |
2427| ** 📉 Best/Worst/Avg Cases** | Analyze with sorted, reversed, and random inputs |
@@ -622,6 +625,104 @@ print(result) # "O(n)"
622625
623626---
624627
628+ ### 2️⃣1️⃣ Git Commit Tracking
629+
630+ Track complexity changes across git commits.
631+
632+ ``` python
633+ from bigocheck import track_commits, find_regression_commit
634+
635+ # Track across specific commits
636+ result = track_commits(
637+ target = " mymodule:myfunc" ,
638+ commits = [" v1.0" , " v1.5" , " v2.0" ],
639+ sizes = [100 , 500 , 1000 ],
640+ )
641+
642+ print (result.summary)
643+ # Tracked 3 commits:
644+ # abc1234: O(n) (Initial implementation...)
645+ # def5678: O(n) (Optimized loop...)
646+ # ghi9012: O(n^2) (Added feature X...)
647+ #
648+ # ❌ Regression detected at ghi9012:
649+ # O(n) → O(n^2)
650+
651+ # Binary search for exact regression commit
652+ bad_commit = find_regression_commit(
653+ target = " mymodule:myfunc" ,
654+ good_commit = " v1.0" ,
655+ bad_commit = " v2.0" ,
656+ sizes = [100 , 500 , 1000 ],
657+ )
658+ print (f " First bad commit: { bad_commit} " )
659+ ```
660+
661+ ---
662+
663+ ### 2️⃣2️⃣ Instability Detection
664+
665+ Detect when benchmark results are unreliable.
666+
667+ ``` python
668+ from bigocheck import benchmark_function, compute_stability, format_stability
669+
670+ analysis = benchmark_function(my_func, sizes = [100 , 500 , 1000 ], trials = 5 )
671+ stability = compute_stability(analysis)
672+
673+ print (format_stability(stability))
674+ # Stability: ✓ Stable (90%)
675+ #
676+ # Warnings:
677+ # ⚠️ Some variance detected in 1 measurements
678+
679+ if stability.is_unstable:
680+ print (" ⚠️ Results may be unreliable!" )
681+ for warning in stability.warnings:
682+ print (f " - { warning} " )
683+ for rec in stability.recommendations:
684+ print (f " → { rec} " )
685+ ```
686+
687+ ---
688+
689+ ### 2️⃣3️⃣ Badge Generation
690+
691+ Generate SVG badges for your README.
692+
693+ ``` python
694+ from bigocheck import benchmark_function, generate_badge, save_badge
695+
696+ analysis = benchmark_function(my_func, sizes = [100 , 500 , 1000 ])
697+
698+ # Generate and save SVG badge
699+ badge = generate_badge(analysis.best_label) # Color-coded by complexity
700+ save_badge(badge, " docs/complexity_badge.svg" )
701+ ```
702+
703+ ** Color Coding:**
704+ | Complexity | Color |
705+ | ------------| -------|
706+ | O(1) | 🟢 Green |
707+ | O(log n) | 🟢 Light Green |
708+ | O(n) | 🟡 Yellow |
709+ | O(n log n) | 🟠 Orange |
710+ | O(n²) | 🔴 Red |
711+ | O(n³+) | 🔴 Dark Red |
712+
713+ ** Use in README:**
714+ ``` markdown
715+ ![ complexity] ( docs/complexity_badge.svg )
716+ ```
717+
718+ ** Or use shields.io URL:**
719+ ``` python
720+ from bigocheck import generate_badge_url
721+
722+ url = generate_badge_url(" O(n log n)" )
723+ # https://img.shields.io/badge/complexity-O%28n%20log%20n%29-fe7d37
724+ ```
725+
625726## 🖥️ CLI Reference
626727
627728``` bash
@@ -734,6 +835,23 @@ from bigocheck import (
734835 start_repl, # Start REPL
735836 quick_check, # One-liner check
736837
838+ # Git Tracking
839+ track_commits, # Track complexity across commits
840+ find_regression_commit, # Binary search for bad commit
841+ CommitResult,
842+ TrackingResult,
843+
844+ # Stability Detection
845+ compute_stability, # Detect unreliable results
846+ format_stability,
847+ StabilityResult,
848+
849+ # Badge Generation
850+ generate_badge, # SVG badge
851+ generate_dual_badge, # Time + space badge
852+ save_badge,
853+ generate_badge_url, # shields.io URL
854+
737855 # Data Classes
738856 Analysis,
739857 Measurement,
@@ -751,7 +869,7 @@ from bigocheck import (
751869```
752870bigocheck/
753871├── src/bigocheck/
754- │ ├── __init__.py # Package exports (25 + functions)
872+ │ ├── __init__.py # Package exports (40 + functions)
755873│ ├── core.py # Benchmarking and fitting
756874│ ├── cli.py # CLI (run, regression, repl)
757875│ ├── assertions.py # @assert_complexity, verify_bounds
@@ -766,13 +884,16 @@ bigocheck/
766884│ ├── amortized.py # Amortized complexity analysis
767885│ ├── parallel.py # Parallel benchmarking
768886│ ├── interactive.py # REPL mode
887+ │ ├── git_tracking.py # Git commit tracking
888+ │ ├── stability.py # Instability detection
889+ │ ├── badges.py # Badge generation
769890│ ├── datagen.py # Data generators
770891│ ├── plotting.py # Optional matplotlib plots
771892│ ├── pytest_plugin.py # pytest integration
772893│ └── pre_commit.py # Pre-commit hook template
773894├── .github/workflows/ # CI/CD templates
774895├── docs/ # Documentation assets
775- ├── tests/ # Test suite (77 + tests)
896+ ├── tests/ # Test suite (78 + tests)
776897├── pyproject.toml
777898├── CITATION.cff
778899└── LICENSE
@@ -799,6 +920,9 @@ pytest -v
799920- Amortized analysis
800921- Parallel benchmarking
801922- HTML report generation
923+ - Git commit tracking
924+ - Instability detection
925+ - Badge generation
802926
803927---
804928
0 commit comments