summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2023-01-23 14:25:30 -0800
committerKenneth Graunke <kenneth@whitecape.org>2023-03-13 00:32:03 -0700
commit1c4f15e0a89772e3b6413c0dc759f546e4b5efa8 (patch)
tree80d412c5ce37fc598da8b4912e3b40b75928712e
parenteed77101d32e5185e5d08f6a11b231adb1c1f123 (diff)
report-fossil: Parse arguments before trying to detect drivers
This fixes ./report-fossil.py --help, which previously just croaked with an error about not being able to detect the driver, because no .csv files were specified on the command line. Which isn't a great error message when you're...trying to figure out the command line. While at it, we also drop the requirement that filenames must end with .csv. The code to check for that was basically to try and distinguish filenames from other arguments...which we don't need to do now that we properly do argument parsing beforehand. They still have to be .csv files, of course, but mandating extensions is a bit unusual. Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
-rwxr-xr-xreport-fossil.py39
1 files changed, 19 insertions, 20 deletions
diff --git a/report-fossil.py b/report-fossil.py
index 3c4b011..7572ef1 100755
--- a/report-fossil.py
+++ b/report-fossil.py
@@ -587,10 +587,24 @@ def get_stat_list(names: typing.Optional[typing.List[str]], all_stats: typing.Li
def main():
drivers: typing.Set[str] = set()
- for arg in sys.argv:
- if not arg.endswith('.csv'):
- continue
- with open(arg, 'rt') as f:
+ parser = argparse.ArgumentParser()
+ parser.add_argument('csv', nargs='+', type=pathlib.Path, help='Path to CSV files')
+ stat_list_arg = {'nargs':'*', 'default':None, 'type':str, 'metavar':'STAT',
+ 'choices':[stat.display_name for stat in statistics if not stat.is_hash]}
+ parser.add_argument('--apps', nargs='+', type=str, metavar='NAME', help='Only consider certain applications')
+ parser.add_argument('--stats', **stat_list_arg, help='Only consider certain statistics')
+ parser.add_argument('--rel-changes', **stat_list_arg, help='Show improvements sorted by relative change')
+ parser.add_argument('--abs-changes', **stat_list_arg, help='Show improvements sorted by absolute change')
+ parser.add_argument('--rel-small-changes', **stat_list_arg, help='Show improvements sorted by relative change divided by code size')
+ parser.add_argument('--affected', action='store_const', const=True, help='Show affected shaders sorted by code size')
+ parser.add_argument('--affected-apps', action='store_const', const=True, help='Show affected applications')
+ parser.add_argument('--worst', **stat_list_arg, help='Show shaders which are worst')
+ parser.add_argument('--best', **stat_list_arg, help='Show shaders which are best')
+ parser.add_argument('--hide-table', action='store_const', const=True, help='Hide the table')
+ args = parser.parse_args()
+
+ for filename in args.csv:
+ with open(filename, 'rt') as f:
reader = csv.reader(f)
row = next(reader)
if 'VGPRs' in row:
@@ -602,7 +616,7 @@ def main():
elif 'TMU Fills' in row:
drivers.add('v3dv')
else:
- print('Cannot guess driver for %s' % arg)
+ print('Cannot guess driver for %s' % filename)
sys.exit(1)
if len(drivers) == 0:
@@ -614,21 +628,6 @@ def main():
driver = next(iter(drivers))
- parser = argparse.ArgumentParser()
- parser.add_argument('csv', nargs='+', type=pathlib.Path, help='Path to CSV files')
- stat_list_arg = {'nargs':'*', 'default':None, 'type':str, 'metavar':'STAT',
- 'choices':[stat.display_name for stat in statistics if not stat.is_hash]}
- parser.add_argument('--apps', nargs='+', type=str, metavar='NAME', help='Only consider certain applications')
- parser.add_argument('--stats', **stat_list_arg, help='Only consider certain statistics')
- parser.add_argument('--rel-changes', **stat_list_arg, help='Show improvements sorted by relative change')
- parser.add_argument('--abs-changes', **stat_list_arg, help='Show improvements sorted by absolute change')
- parser.add_argument('--rel-small-changes', **stat_list_arg, help='Show improvements sorted by relative change divided by code size')
- parser.add_argument('--affected', action='store_const', const=True, help='Show affected shaders sorted by code size')
- parser.add_argument('--affected-apps', action='store_const', const=True, help='Show affected applications')
- parser.add_argument('--worst', **stat_list_arg, help='Show shaders which are worst')
- parser.add_argument('--best', **stat_list_arg, help='Show shaders which are best')
- parser.add_argument('--hide-table', action='store_const', const=True, help='Hide the table')
- args = parser.parse_args()
inc_statistics = None
if args.stats: