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)) 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)