From 41c944cc815c9c08e65ac570db7e19c68db26849 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2026 19:46:39 +0000 Subject: [PATCH] Refactor stress test aggregation to use a single pass loop. Co-authored-by: daggerstuff <261005129+daggerstuff@users.noreply.github.com> --- lab/tests/stress/stress_test_framework.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lab/tests/stress/stress_test_framework.py b/lab/tests/stress/stress_test_framework.py index 931813b0..0076bf21 100644 --- a/lab/tests/stress/stress_test_framework.py +++ b/lab/tests/stress/stress_test_framework.py @@ -231,15 +231,17 @@ def concurrent_insert_test( total_duration = end_time - start_time # Aggregate results - successful_results = [r for r in results if r.get("success", False)] - failed_results = [r for r in results if not r.get("success", False)] + successful_batches = 0 + total_conversations_inserted = 0 + total_messages_inserted = 0 - total_conversations_inserted = sum( - r.get("conversations_inserted", 0) for r in successful_results - ) - total_messages_inserted = sum( - r.get("messages_inserted", 0) for r in successful_results - ) + for r in results: + if r.get("success", False): + successful_batches += 1 + total_conversations_inserted += r.get("conversations_inserted", 0) + total_messages_inserted += r.get("messages_inserted", 0) + + failed_batches = len(results) - successful_batches return { "total_duration": total_duration, @@ -252,8 +254,8 @@ def concurrent_insert_test( "overall_messages_per_second": total_messages_inserted / total_duration if total_duration > 0 else 0, - "successful_batches": len(successful_results), - "failed_batches": len(failed_results), + "successful_batches": successful_batches, + "failed_batches": failed_batches, "batch_results": results, }