Skip to content

Commit

Permalink
[Perf] Include running average in per-second output (Azure#16302)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeharder authored Jan 22, 2021
1 parent f8be630 commit c957c4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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("")

Expand Down Expand Up @@ -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))
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit c957c4f

Please sign in to comment.