From a607965e5f25ff5ce739a5e25ad5a82b09cfaba1 Mon Sep 17 00:00:00 2001 From: maurycy <5383+maurycy@users.noreply.github.com> Date: Wed, 10 Jun 2026 10:16:47 +0200 Subject: [PATCH] batching --- .../benchmark_external_inspection.py | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/Tools/inspection/benchmark_external_inspection.py b/Tools/inspection/benchmark_external_inspection.py index 8e367422a961da..22139b50836caf 100644 --- a/Tools/inspection/benchmark_external_inspection.py +++ b/Tools/inspection/benchmark_external_inspection.py @@ -243,25 +243,28 @@ def benchmark(unwinder, duration_seconds=10, blocking=False, operation="stack_tr f"for {duration_seconds} seconds...{colors.RESET}" ) + BATCH = 1000 try: - while time.perf_counter() < end_time: - total_attempts += 1 - work_start = time.perf_counter() - try: - if blocking: - unwinder.pause_threads() + while True: + batch_start = time.perf_counter() + if batch_start >= end_time: + break + for _ in range(BATCH): + total_attempts += 1 try: - sample = operation_method() - if sample: - sample_count += 1 - finally: if blocking: - unwinder.resume_threads() - except (OSError, RuntimeError, UnicodeDecodeError) as e: - fail_count += 1 - - work_end = time.perf_counter() - total_work_time += work_end - work_start + unwinder.pause_threads() + try: + sample = operation_method() + if sample: + sample_count += 1 + finally: + if blocking: + unwinder.resume_threads() + except (OSError, RuntimeError, UnicodeDecodeError) as e: + fail_count += 1 + + total_work_time += time.perf_counter() - batch_start if total_attempts % 10000 == 0: avg_work_time_us = (total_work_time / total_attempts) * 1e6