Skip to content

Commit c957c4f

Browse files
authored
[Perf] Include running average in per-second output (Azure#16302)
1 parent f8be630 commit c957c4f

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_runner.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ def __init__(self, test_folder_path=None):
3434
self._parse_args()
3535

3636

37+
def _get_completed_operations(self):
38+
return sum(self._completed_operations)
39+
40+
41+
def _get_operations_per_second(self):
42+
return sum(map(
43+
lambda x: x[0] / x[1] if x[1] else 0,
44+
zip(self._completed_operations, self._last_completion_times)))
45+
46+
3747
def _parse_args(self):
3848
# First, detect which test we're running.
3949
arg_parser = argparse.ArgumentParser(
@@ -157,14 +167,12 @@ async def _run_tests(self, tests, duration, title):
157167
self.logger.info("")
158168
self.logger.info("=== Results ===")
159169

160-
total_operations = sum(self._completed_operations)
161-
operations_per_second = sum(map(
162-
lambda x: x[0] / x[1],
163-
zip(self._completed_operations, self._last_completion_times)))
170+
total_operations = self._get_completed_operations()
171+
operations_per_second = self._get_operations_per_second()
164172
seconds_per_operation = 1 / operations_per_second
165173
weighted_average_seconds = total_operations / operations_per_second
166174

167-
self.logger.info("Completed {} operations in a weighted-average of {:.2f}s ({:.2f} ops/s, {:.3f} s/op)".format(
175+
self.logger.info("Completed {:,} operations in a weighted-average of {:,.2f}s ({:,.2f} ops/s, {:,.3f} s/op)".format(
168176
total_operations, weighted_average_seconds, operations_per_second, seconds_per_operation))
169177
self.logger.info("")
170178

@@ -192,8 +200,11 @@ async def _run_async_loop(self, test, duration, id):
192200
def _print_status(self, title):
193201
if self._last_total_operations == -1:
194202
self._last_total_operations = 0
195-
self.logger.info("=== {} ===\nCurrent\t\tTotal".format(title))
203+
self.logger.info("=== {} ===\nCurrent\t\tTotal\t\tAverage".format(title))
204+
205+
total_operations = self._get_completed_operations()
206+
current_operations = total_operations - self._last_total_operations
207+
average_operations = self._get_operations_per_second()
196208

197-
total_operations = sum(self._completed_operations)
198-
self.logger.info("{}\t\t{}".format(total_operations - self._last_total_operations, total_operations))
199209
self._last_total_operations = total_operations
210+
self.logger.info("{}\t\t{}\t\t{:.2f}".format(current_operations, total_operations, average_operations))

tools/azure-devtools/src/azure_devtools/perfstress_tests/system_perfstress/sleep_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class SleepTest(PerfStressTest):
1515
instance_count = 0
1616

17-
def __init__(self):
17+
def __init__(self, arguments):
1818
type(self).instance_count += 1
1919
self.seconds_per_operation = math.pow(2, type(self).instance_count)
2020

0 commit comments

Comments
 (0)