Skip to content

Commit

Permalink
Add the repetition parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
karel-brinda committed Jun 7, 2024
1 parent ae32a8d commit f4b81f2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions galitime/galitime.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
VERSION = "(version NA)"

DEFAULT_L = "stderr"
DEFAULT_r = 1


class TimingResult:
Expand Down Expand Up @@ -217,7 +218,7 @@ def _parse_result(self):
# self.current_result[k] = v


def run_timing(log_file, command, experiment, gtime):
def run_timing(log_file, command, experiment, gtime, repetitions):
"""
Run a benchmarking command and log the results.
Expand Down Expand Up @@ -246,7 +247,7 @@ def run_timing(log_file, command, experiment, gtime):
else:
raise Exception(f"Unsupported OS ({platf})")

t.run()
t.run(times=repetitions)

if log_file == "stdout" or log_file == "-":
print(t)
Expand Down Expand Up @@ -315,6 +316,11 @@ def format_help(self):
version='{} {}'.format(PROGRAM, VERSION),
)

parser.add_argument(
'-r', '--repetitions', dest='reps', metavar='INT', type=int, default=DEFAULT_r,
help=f'number of repetitions [{DEFAULT_r}]'
)

parser.add_argument(
'-g', '--gtime', dest='gtime', action='store_true', help=f'call gtime instead of time'
)
Expand All @@ -332,7 +338,8 @@ def format_help(self):
args = parser.parse_args()

run_timing(
log_file=args.log, experiment=args.experiment, command=args.command, gtime=args.gtime
log_file=args.log, experiment=args.experiment, command=args.command, gtime=args.gtime,
repetitions=args.reps
)


Expand Down

0 comments on commit f4b81f2

Please sign in to comment.