From acf4bdc6987ee923c13c35d4ada3460bda2a445c Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 22 Jan 2021 11:29:43 -0800 Subject: [PATCH 1/2] [Perf] Fix ctor in SleepTest --- .../perfstress_tests/system_perfstress/sleep_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/azure-devtools/src/azure_devtools/perfstress_tests/system_perfstress/sleep_test.py b/tools/azure-devtools/src/azure_devtools/perfstress_tests/system_perfstress/sleep_test.py index eb92d6b54b65..c4f37867f79e 100644 --- a/tools/azure-devtools/src/azure_devtools/perfstress_tests/system_perfstress/sleep_test.py +++ b/tools/azure-devtools/src/azure_devtools/perfstress_tests/system_perfstress/sleep_test.py @@ -14,7 +14,7 @@ class SleepTest(PerfStressTest): instance_count = 0 - def __init__(self): + def __init__(self, arguments): type(self).instance_count += 1 self.seconds_per_operation = math.pow(2, type(self).instance_count) From bdd57fcdb8cf4fe60188a66feea0583bb26edfda Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 22 Jan 2021 11:30:22 -0800 Subject: [PATCH 2/2] [Perf] Include running average in per-second output --- .../perfstress_tests/perf_stress_runner.py | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_runner.py b/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_runner.py index f90c246d848c..dd8a7306cafc 100644 --- a/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_runner.py +++ b/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_runner.py @@ -34,6 +34,16 @@ def __init__(self, test_folder_path=None): self._parse_args() + def _get_completed_operations(self): + return sum(self._completed_operations) + + + def _get_operations_per_second(self): + return sum(map( + lambda x: x[0] / x[1] if x[1] else 0, + zip(self._completed_operations, self._last_completion_times))) + + def _parse_args(self): # First, detect which test we're running. arg_parser = argparse.ArgumentParser( @@ -157,14 +167,12 @@ async def _run_tests(self, tests, duration, title): self.logger.info("") self.logger.info("=== Results ===") - total_operations = sum(self._completed_operations) - operations_per_second = sum(map( - lambda x: x[0] / x[1], - zip(self._completed_operations, self._last_completion_times))) + total_operations = self._get_completed_operations() + operations_per_second = self._get_operations_per_second() seconds_per_operation = 1 / operations_per_second weighted_average_seconds = total_operations / operations_per_second - self.logger.info("Completed {} operations in a weighted-average of {:.2f}s ({:.2f} ops/s, {:.3f} s/op)".format( + self.logger.info("Completed {:,} operations in a weighted-average of {:,.2f}s ({:,.2f} ops/s, {:,.3f} s/op)".format( total_operations, weighted_average_seconds, operations_per_second, seconds_per_operation)) self.logger.info("") @@ -192,8 +200,11 @@ async def _run_async_loop(self, test, duration, id): def _print_status(self, title): if self._last_total_operations == -1: self._last_total_operations = 0 - self.logger.info("=== {} ===\nCurrent\t\tTotal".format(title)) + self.logger.info("=== {} ===\nCurrent\t\tTotal\t\tAverage".format(title)) + + total_operations = self._get_completed_operations() + current_operations = total_operations - self._last_total_operations + average_operations = self._get_operations_per_second() - total_operations = sum(self._completed_operations) - self.logger.info("{}\t\t{}".format(total_operations - self._last_total_operations, total_operations)) self._last_total_operations = total_operations + self.logger.info("{}\t\t{}\t\t{:.2f}".format(current_operations, total_operations, average_operations))