Skip to content

Commit

Permalink
grass.benchmark: compute parallel efficiency (#2319)
Browse files Browse the repository at this point in the history
Adds only the computing of parallel efficiency, not plotting it.
  • Loading branch information
petrasovaa committed Apr 22, 2022
1 parent 9c4ded9 commit b95f3ee
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python/grass/benchmark/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ def benchmark_nprocs(module, label, max_nprocs, repeat=5, shuffle=True):
Optional *nprocs* is passed to the module if present.
Returns an object with attributes *times* (list of average execution times),
*all_times* (list of lists of measured execution times), *nprocs*
(list of *nprocs* values used), and *label* (the provided parameter as is).
*all_times* (list of lists of measured execution times),
*efficiency* (parallel efficiency), *nprocs* (list of *nprocs* values used),
and *label* (the provided parameter as is).
"""
term_size = shutil.get_terminal_size()
if hasattr(module, "get_bash"):
Expand All @@ -104,6 +105,7 @@ def benchmark_nprocs(module, label, max_nprocs, repeat=5, shuffle=True):
serial_avg = None
avg_times = []
all_times = []
efficiency = []
nprocs_list = list(range(1, max_nprocs + 1))
nprocs_list_shuffled = sorted(nprocs_list * repeat)
if shuffle:
Expand All @@ -127,6 +129,7 @@ def benchmark_nprocs(module, label, max_nprocs, repeat=5, shuffle=True):
if avg < min_avg:
min_avg = avg
min_time = nprocs
efficiency.append(serial_avg / (nprocs * avg))

print("\u2500" * term_size.columns)
if serial_avg is not None:
Expand All @@ -136,6 +139,7 @@ def benchmark_nprocs(module, label, max_nprocs, repeat=5, shuffle=True):
return SimpleNamespace(
all_times=all_times,
times=avg_times,
efficiency=efficiency,
nprocs=nprocs_list,
label=label,
)
Expand Down

0 comments on commit b95f3ee

Please sign in to comment.