|
38 | 38 | # SOFTWARE.
|
39 | 39 |
|
40 | 40 | import _io
|
41 |
| -import argparse |
42 | 41 | import os
|
43 | 42 | import sys
|
44 | 43 | from time import time
|
@@ -120,14 +119,31 @@ def run(self):
|
120 | 119 |
|
121 | 120 |
|
122 | 121 | def run_benchmark(prog, args):
|
123 |
| - parser = argparse.ArgumentParser(prog=prog, description="Run specified benchmark.") |
124 |
| - parser.add_argument("-w", "--warmup", help="The number of iterations to skip as warmup.", default=0) |
125 |
| - parser.add_argument("-i", "--iterations", help="The number of iterations top run each benchmark.", default=1) |
126 |
| - parser.add_argument("bench_file", metavar='BENCH', help="Path to the benchmark to execute.", nargs=1) |
127 |
| - parser.add_argument("bench_args", metavar='ARGS', help="Path to the benchmarks to execute.", nargs='*', default=None) |
128 |
| - |
129 |
| - args = parser.parse_args(args) |
130 |
| - BenchRunner(args.bench_file[0], bench_args=args.bench_args, iterations=args.iterations, warmup=args.warmup).run() |
| 122 | + warmup = 0 |
| 123 | + iterations = 1 |
| 124 | + bench_file = None |
| 125 | + bench_args = [] |
| 126 | + |
| 127 | + i = 0 |
| 128 | + while i < len(args): |
| 129 | + arg = args[i] |
| 130 | + if arg == '-i': |
| 131 | + i += 1 |
| 132 | + iterations = _as_int(args[i]) |
| 133 | + elif arg.startswith("--iterations"): |
| 134 | + iterations = _as_int(arg.split("=")[1]) |
| 135 | + elif arg == '-w': |
| 136 | + i += 1 |
| 137 | + warmup = _as_int(args[i]) |
| 138 | + elif arg.startswith("--warmup"): |
| 139 | + warmup = _as_int(arg.split("=")[1]) |
| 140 | + elif bench_file is None: |
| 141 | + bench_file = arg |
| 142 | + else: |
| 143 | + bench_args.append(arg) |
| 144 | + i += 1 |
| 145 | + |
| 146 | + BenchRunner(bench_file, bench_args=bench_args, iterations=iterations, warmup=warmup).run() |
131 | 147 |
|
132 | 148 |
|
133 | 149 | if __name__ == '__main__':
|
|
0 commit comments