From 473b826c9b6decba18112eba6ed441223cc5cf03 Mon Sep 17 00:00:00 2001 From: Ian Hunter Date: Fri, 17 Nov 2023 12:08:47 +0000 Subject: [PATCH] Apply suggestions from code review Signed-off-by: Ian Hunter --- scripts/benchmark/benchmark_core.py | 34 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/scripts/benchmark/benchmark_core.py b/scripts/benchmark/benchmark_core.py index 060602cce..0d169a67d 100644 --- a/scripts/benchmark/benchmark_core.py +++ b/scripts/benchmark/benchmark_core.py @@ -15,13 +15,15 @@ def __init__(self, start_range=0, end_range=10): self.range = range(start_range, end_range) self.plt = plt - def add_function(self, - name, - f, - color="r", - marker="o", - hard_limit=None, - override=None): + def add_function( + self, + name, + f, + color="r", + marker="o", + hard_limit=None, + override=None + ): """Adds a function to the list of functions to benchmark. @name - Human Readable name @f - function @@ -81,9 +83,11 @@ def benchmark(self, title): # ------ BENCHMARK ------ time1 = time.time() try: - func_timeout.func_timeout(self.TIMEOUT_SECONDS, - roll_fn, - args=[r]) + func_timeout.func_timeout( + self.TIMEOUT_SECONDS, + roll_fn, + args=[r] + ) except (Exception, func_timeout.FunctionTimedOut) as e: print(f"Err: {c['name']}:{r}") print("\t", e) @@ -102,10 +106,12 @@ def benchmark(self, title): y.append(tt * 1000) if y: - plt.plot(shared_x[0:len(y)], - y, - color=c["color"], - marker=c["marker"]) + plt.plot( + shared_x[0:len(y)], + y, + color=c["color"], + marker=c["marker"] + ) print("Result:", y) # Configuration and Output