Run benchmarks with different sizes.
()
| 228 | |
| 229 | |
| 230 | def main(): |
| 231 | """Run benchmarks with different sizes.""" |
| 232 | sizes = [1000, 10000, 50000] if "--full" in sys.argv else [10000] |
| 233 | |
| 234 | all_results = {} |
| 235 | |
| 236 | for size in sizes: |
| 237 | print(f"\n{'='*60}") |
| 238 | print(f"Running benchmarks for size: {size:,}") |
| 239 | print("=" * 60) |
| 240 | |
| 241 | suite = BenchmarkSuite(size) |
| 242 | results = suite.run_all_benchmarks() |
| 243 | all_results[size] = results |
| 244 | |
| 245 | print(format_results(results)) |
| 246 | |
| 247 | # Save results if requested |
| 248 | if "--save" in sys.argv: |
| 249 | filename = save_results(all_results) |
| 250 | print(f"\nResults saved to: {filename}") |
| 251 | |
| 252 | # Check for performance regressions |
| 253 | if "--check-regression" in sys.argv: |
| 254 | # Simple regression check - you can make this more sophisticated |
| 255 | baseline_size = 10000 |
| 256 | if baseline_size in all_results: |
| 257 | sequential_time = all_results[baseline_size]["sequential_insertion"][ |
| 258 | "duration" |
| 259 | ] |
| 260 | if sequential_time > 0.5: # 0.5 seconds threshold |
| 261 | print( |
| 262 | f"\n⚠️ WARNING: Sequential insertion took {sequential_time:.4f}s, " |
| 263 | f"exceeding threshold of 0.5s" |
| 264 | ) |
| 265 | sys.exit(1) |
| 266 | |
| 267 | print("\n✅ All benchmarks completed successfully!") |
| 268 | |
| 269 | |
| 270 | if __name__ == "__main__": |
no test coverage detected