Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Perf] Include running average in per-second output #16302

Merged
merged 2 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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