From f4b81f2073f7026287f5d9aa265a048af584ce2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20B=C5=99inda?= Date: Fri, 7 Jun 2024 14:48:41 +0200 Subject: [PATCH] Add the repetition parameter --- galitime/galitime.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/galitime/galitime.py b/galitime/galitime.py index 73261fd..e8275bb 100755 --- a/galitime/galitime.py +++ b/galitime/galitime.py @@ -24,6 +24,7 @@ VERSION = "(version NA)" DEFAULT_L = "stderr" +DEFAULT_r = 1 class TimingResult: @@ -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. @@ -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) @@ -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' ) @@ -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 )