Run a performance comparison between sequential and batch processing This function can be called separately for benchmarking
()
| 397 | |
| 398 | |
| 399 | def run_performance_comparison(): |
| 400 | """ |
| 401 | Run a performance comparison between sequential and batch processing |
| 402 | This function can be called separately for benchmarking |
| 403 | """ |
| 404 | print("Running Performance Comparison...") |
| 405 | |
| 406 | test_suite = TestPerformanceBenches() |
| 407 | test_suite.setUp() |
| 408 | |
| 409 | # Run performance test |
| 410 | seq_responses, seq_time = test_suite.measure_sequential_processing(test_suite.test_prompts) |
| 411 | batch_responses, batch_time = test_suite.measure_batch_processing(test_suite.test_prompts) |
| 412 | |
| 413 | print(f"Sequential processing: {seq_time:.3f}s") |
| 414 | print(f"Batch processing: {batch_time:.3f}s") |
| 415 | print(f"Speedup: {seq_time/batch_time:.2f}x") |
| 416 | |
| 417 | return { |
| 418 | "sequential_time": seq_time, |
| 419 | "batch_time": batch_time, |
| 420 | "speedup": seq_time/batch_time |
| 421 | } |
| 422 | |
| 423 | |
| 424 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected