Run comprehensive benchmark suite.
(self)
| 490 | ) |
| 491 | |
| 492 | def run_benchmarks(self): |
| 493 | """Run comprehensive benchmark suite.""" |
| 494 | print("="*80) |
| 495 | print("TOKENIZER PERFORMANCE BENCHMARK") |
| 496 | print("="*80) |
| 497 | print(f"Warmup runs: {self.warmup_runs}") |
| 498 | print(f"Benchmark runs: {self.benchmark_runs}") |
| 499 | print() |
| 500 | |
| 501 | # Generate test corpus |
| 502 | print("Generating test corpus...") |
| 503 | test_texts = self.generate_test_texts() |
| 504 | |
| 505 | total_tests = sum(len(texts) for texts in test_texts.values()) |
| 506 | current_test = 0 |
| 507 | |
| 508 | # Run benchmarks |
| 509 | for category, texts in test_texts.items(): |
| 510 | print(f"\n--- {category.upper().replace('_', ' ')} ---") |
| 511 | |
| 512 | for i, text in enumerate(texts): |
| 513 | current_test += 1 |
| 514 | test_name = f"{category}_{i}" |
| 515 | |
| 516 | print(f"[{current_test:3d}/{total_tests}] {test_name:<30} " |
| 517 | f"({len(text):6d} chars)", end=" ... ", flush=True) |
| 518 | |
| 519 | result = self.benchmark_single_text(test_name, text) |
| 520 | self.results.append(result) |
| 521 | |
| 522 | # Print quick result |
| 523 | if result.speedup_ratio != float('inf'): |
| 524 | speedup_indicator = "🚀" if result.speedup_ratio > 1.5 else "⚡" if result.speedup_ratio > 1.0 else "🐌" |
| 525 | print(f"{speedup_indicator} {result.speedup_ratio:.2f}x speedup") |
| 526 | else: |
| 527 | print("❌ ERROR") |
| 528 | |
| 529 | def print_summary_report(self): |
| 530 | """Print comprehensive performance analysis.""" |
no test coverage detected