forked from Imagelibrary/littlefs
scripts: Changed -o/-O to an exclusive operation
So: $ ./scripts/code.py lfs.o -o- -q Becomes: $ ./scripts/code.py lfs.o -o- The original intention of -o/-O _not_ being exclusive (aka table is still rendered unless disabled with -q/--quiet), was to allow results to be written to csv files and rendered to tables in a single pass. But this was never useful. Heck, we're not even using this in our Makefile right now because it would make the rule dependencies more complicated than it's worth. Even for long-running result scripts (perf.py, perfbd.py, etc), most of the work is building that csv file, the cost of rendering a table in a second pass is negligible. In every case I've used -o/-O, I've also wanted -q/--quiet, and almost always forget this on the first run. So might as well make the expected behavior the actual behavior. --- As a plus, this let us simplify some of the scripts a bit, by replacing visibility filters with -o/-O dependent by-fields.
This commit is contained in:
@@ -1027,18 +1027,6 @@ def main(obj_paths, *,
|
||||
by=by,
|
||||
defines=defines)
|
||||
|
||||
# write results to CSV/JSON
|
||||
if args.get('output'):
|
||||
write_csv(args['output'], CodeResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
**args)
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], CodeResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
**args)
|
||||
|
||||
# find previous results?
|
||||
diff_results = None
|
||||
if args.get('diff') or args.get('percent'):
|
||||
@@ -1055,8 +1043,20 @@ def main(obj_paths, *,
|
||||
by=by,
|
||||
defines=defines)
|
||||
|
||||
# write results to JSON
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], CodeResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
**args)
|
||||
# write results to CSV
|
||||
elif args.get('output'):
|
||||
write_csv(args['output'], CodeResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
**args)
|
||||
# print table
|
||||
if not args.get('quiet'):
|
||||
else:
|
||||
table(CodeResult, results, diff_results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
@@ -1078,10 +1078,6 @@ if __name__ == "__main__":
|
||||
'-v', '--verbose',
|
||||
action='store_true',
|
||||
help="Output commands that run behind the scenes.")
|
||||
parser.add_argument(
|
||||
'-q', '--quiet',
|
||||
action='store_true',
|
||||
help="Don't show anything, useful with -o.")
|
||||
parser.add_argument(
|
||||
'-o', '--output',
|
||||
help="Specify CSV file to store results.")
|
||||
|
||||
@@ -953,13 +953,17 @@ def main(gcda_paths, *,
|
||||
else:
|
||||
by = ['function']
|
||||
|
||||
visible = None
|
||||
if fields is None:
|
||||
if (args.get('annotate')
|
||||
or args.get('lines')
|
||||
or args.get('branches')
|
||||
or args.get('output')
|
||||
or args.get('output_json')):
|
||||
fields = ['calls', 'hits', 'funcs', 'lines', 'branches']
|
||||
if not hits:
|
||||
visible = ['lines', 'branches']
|
||||
elif not hits:
|
||||
fields = ['lines', 'branches']
|
||||
else:
|
||||
visible = ['calls', 'hits']
|
||||
fields = ['calls', 'hits']
|
||||
|
||||
# find sizes
|
||||
if not args.get('use', None):
|
||||
@@ -982,18 +986,6 @@ def main(gcda_paths, *,
|
||||
by=by,
|
||||
defines=defines)
|
||||
|
||||
# write results to CSV/JSON
|
||||
if args.get('output'):
|
||||
write_csv(args['output'], CovResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
**args)
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], CovResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
**args)
|
||||
|
||||
# find previous results?
|
||||
diff_results = None
|
||||
if args.get('diff') or args.get('percent'):
|
||||
@@ -1010,18 +1002,28 @@ def main(gcda_paths, *,
|
||||
by=by,
|
||||
defines=defines)
|
||||
|
||||
# print table
|
||||
if not args.get('quiet'):
|
||||
# annotate sources
|
||||
if (args.get('annotate')
|
||||
or args.get('lines')
|
||||
or args.get('branches')):
|
||||
# annotate sources
|
||||
annotate(CovResult, results, **args)
|
||||
else:
|
||||
# write results to JSON
|
||||
elif args.get('output_json'):
|
||||
write_csv(args['output_json'], CovResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
**args)
|
||||
# write results to CSV
|
||||
elif args.get('output'):
|
||||
write_csv(args['output'], CovResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
**args)
|
||||
# print table
|
||||
else:
|
||||
table(CovResult, results, diff_results,
|
||||
by=by,
|
||||
fields=visible if visible is not None else fields,
|
||||
fields=fields,
|
||||
sort=sort,
|
||||
**args)
|
||||
|
||||
@@ -1048,10 +1050,6 @@ if __name__ == "__main__":
|
||||
'-v', '--verbose',
|
||||
action='store_true',
|
||||
help="Output commands that run behind the scenes.")
|
||||
parser.add_argument(
|
||||
'-q', '--quiet',
|
||||
action='store_true',
|
||||
help="Don't show anything, useful with -o.")
|
||||
parser.add_argument(
|
||||
'-o', '--output',
|
||||
help="Specify CSV file to store results.")
|
||||
|
||||
@@ -2206,10 +2206,11 @@ def main(csv_paths, *,
|
||||
if by is not None:
|
||||
labels = [k for (k, v), hidden in by if not hidden]
|
||||
by = [k for (k, v), hidden in by]
|
||||
visible = None
|
||||
if fields is not None:
|
||||
visible = [k for (k, v), hidden in fields if not hidden]
|
||||
fields = [k for (k, v), hidden in fields]
|
||||
fields = [k for (k, v), hidden in fields
|
||||
if not hidden
|
||||
or args.get('output')
|
||||
or args.get('output_json')]
|
||||
if sort is not None:
|
||||
sort = [(k, reverse) for (k, v), reverse in sort]
|
||||
if hot is not None:
|
||||
@@ -2293,20 +2294,6 @@ def main(csv_paths, *,
|
||||
depth=depth,
|
||||
hot=hot)
|
||||
|
||||
# write results to CSV/JSON
|
||||
if args.get('output'):
|
||||
write_csv(args['output'], Result, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], Result, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
|
||||
# find previous results?
|
||||
diff_results = None
|
||||
if args.get('diff') or args.get('percent'):
|
||||
@@ -2343,11 +2330,25 @@ def main(csv_paths, *,
|
||||
depth=depth,
|
||||
hot=hot)
|
||||
|
||||
# write results to JSON
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], Result, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
# write results to CSV
|
||||
elif args.get('output'):
|
||||
write_csv(args['output'], Result, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
# print table
|
||||
if not args.get('quiet'):
|
||||
else:
|
||||
table(Result, results, diff_results,
|
||||
by=by,
|
||||
fields=visible if visible is not None else fields,
|
||||
fields=fields,
|
||||
sort=sort,
|
||||
labels=labels,
|
||||
depth=depth,
|
||||
@@ -2372,10 +2373,6 @@ if __name__ == "__main__":
|
||||
'--help-exprs',
|
||||
action='store_true',
|
||||
help="Show what field exprs are available.")
|
||||
parser.add_argument(
|
||||
'-q', '--quiet',
|
||||
action='store_true',
|
||||
help="Don't show anything, useful with -o.")
|
||||
parser.add_argument(
|
||||
'-o', '--output',
|
||||
help="Specify CSV file to store results.")
|
||||
|
||||
@@ -1268,10 +1268,12 @@ def main(obj_paths, *,
|
||||
else:
|
||||
by = ['function']
|
||||
|
||||
visible = None
|
||||
if fields is None:
|
||||
if (args.get('output')
|
||||
or args.get('output_json')):
|
||||
fields = ['off', 'size']
|
||||
visible = ['size']
|
||||
else:
|
||||
fields = ['size']
|
||||
|
||||
# figure out depth
|
||||
if depth is None:
|
||||
@@ -1309,20 +1311,6 @@ def main(obj_paths, *,
|
||||
depth=depth,
|
||||
hot=hot)
|
||||
|
||||
# write results to CSV/JSON
|
||||
if args.get('output'):
|
||||
write_csv(args['output'], CtxResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], CtxResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
|
||||
# find previous results?
|
||||
diff_results = None
|
||||
if args.get('diff') or args.get('percent'):
|
||||
@@ -1347,11 +1335,25 @@ def main(obj_paths, *,
|
||||
depth=depth,
|
||||
hot=hot)
|
||||
|
||||
# write results to JSON
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], CtxResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
# write results to CSV
|
||||
elif args.get('output'):
|
||||
write_csv(args['output'], CtxResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
# print table
|
||||
if not args.get('quiet'):
|
||||
else:
|
||||
table(CtxResult, results, diff_results,
|
||||
by=by,
|
||||
fields=visible if visible is not None else fields,
|
||||
fields=fields,
|
||||
sort=sort,
|
||||
labels=labels,
|
||||
depth=depth,
|
||||
@@ -1372,10 +1374,6 @@ if __name__ == "__main__":
|
||||
'-v', '--verbose',
|
||||
action='store_true',
|
||||
help="Output commands that run behind the scenes.")
|
||||
parser.add_argument(
|
||||
'-q', '--quiet',
|
||||
action='store_true',
|
||||
help="Don't show anything, useful with -o.")
|
||||
parser.add_argument(
|
||||
'-o', '--output',
|
||||
help="Specify CSV file to store results.")
|
||||
|
||||
@@ -1027,18 +1027,6 @@ def main(obj_paths, *,
|
||||
by=by,
|
||||
defines=defines)
|
||||
|
||||
# write results to CSV/JSON
|
||||
if args.get('output'):
|
||||
write_csv(args['output'], DataResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
**args)
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], DataResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
**args)
|
||||
|
||||
# find previous results?
|
||||
diff_results = None
|
||||
if args.get('diff') or args.get('percent'):
|
||||
@@ -1055,8 +1043,20 @@ def main(obj_paths, *,
|
||||
by=by,
|
||||
defines=defines)
|
||||
|
||||
# write results to JSON
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], DataResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
**args)
|
||||
# write results to CSV
|
||||
elif args.get('output'):
|
||||
write_csv(args['output'], DataResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
**args)
|
||||
# print table
|
||||
if not args.get('quiet'):
|
||||
else:
|
||||
table(DataResult, results, diff_results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
@@ -1078,10 +1078,6 @@ if __name__ == "__main__":
|
||||
'-v', '--verbose',
|
||||
action='store_true',
|
||||
help="Output commands that run behind the scenes.")
|
||||
parser.add_argument(
|
||||
'-q', '--quiet',
|
||||
action='store_true',
|
||||
help="Don't show anything, useful with -o.")
|
||||
parser.add_argument(
|
||||
'-o', '--output',
|
||||
help="Specify CSV file to store results.")
|
||||
|
||||
@@ -1484,15 +1484,18 @@ def report(perf_paths, *,
|
||||
else:
|
||||
by = ['function']
|
||||
|
||||
visible = None
|
||||
if fields is None:
|
||||
if (args.get('annotate')
|
||||
or args.get('threshold')
|
||||
or args.get('output')
|
||||
or args.get('output_json')):
|
||||
fields = ['cycles', 'bmisses', 'branches', 'cmisses', 'caches']
|
||||
if not branches and not caches:
|
||||
visible = ['cycles']
|
||||
elif not branches and not caches:
|
||||
fields = ['cycles']
|
||||
elif branches:
|
||||
visible = ['bmisses', 'branches']
|
||||
fields = ['bmisses', 'branches']
|
||||
else:
|
||||
visible = ['cmisses', 'caches']
|
||||
fields = ['cmisses', 'caches']
|
||||
|
||||
# figure out depth
|
||||
if depth is None:
|
||||
@@ -1530,20 +1533,6 @@ def report(perf_paths, *,
|
||||
depth=depth,
|
||||
hot=hot)
|
||||
|
||||
# write results to CSV/JSON
|
||||
if args.get('output'):
|
||||
write_csv(args['output'], PerfResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], PerfResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
|
||||
# find previous results?
|
||||
diff_results = None
|
||||
if args.get('diff') or args.get('percent'):
|
||||
@@ -1569,19 +1558,31 @@ def report(perf_paths, *,
|
||||
hot=hot)
|
||||
|
||||
# print table
|
||||
if not args.get('quiet'):
|
||||
if (args.get('annotate')
|
||||
or args.get('threshold')):
|
||||
# annotate sources
|
||||
annotate(PerfResult, results,
|
||||
branches=branches,
|
||||
caches=caches,
|
||||
**args)
|
||||
# write results to JSON
|
||||
elif args.get('output_json'):
|
||||
write_csv(args['output_json'], PerfResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
# write results to CSV
|
||||
elif args.get('output'):
|
||||
write_csv(args['output'], PerfResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
else:
|
||||
# print table
|
||||
table(PerfResult, results, diff_results,
|
||||
by=by,
|
||||
fields=visible if visible is not None else fields,
|
||||
fields=fields,
|
||||
sort=sort,
|
||||
labels=labels,
|
||||
depth=depth,
|
||||
@@ -1621,10 +1622,6 @@ if __name__ == "__main__":
|
||||
'-v', '--verbose',
|
||||
action='store_true',
|
||||
help="Output commands that run behind the scenes.")
|
||||
parser.add_argument(
|
||||
'-q', '--quiet',
|
||||
action='store_true',
|
||||
help="Don't show anything, useful with -o.")
|
||||
parser.add_argument(
|
||||
'-o', '--output',
|
||||
help="Specify CSV file to store results.")
|
||||
|
||||
@@ -1525,20 +1525,6 @@ def report(paths, *,
|
||||
depth=depth,
|
||||
hot=hot)
|
||||
|
||||
# write results to CSV/JSON
|
||||
if args.get('output'):
|
||||
write_csv(args['output'], PerfBdResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], PerfBdResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
|
||||
# find previous results?
|
||||
diff_results = None
|
||||
if args.get('diff') or args.get('percent'):
|
||||
@@ -1564,16 +1550,28 @@ def report(paths, *,
|
||||
hot=hot)
|
||||
|
||||
# print table
|
||||
if not args.get('quiet'):
|
||||
if (args.get('annotate')
|
||||
or args.get('threshold')
|
||||
or args.get('read_threshold')
|
||||
or args.get('prog_threshold')
|
||||
or args.get('erase_threshold')):
|
||||
# annotate sources
|
||||
annotate(PerfBdResult, results, **args)
|
||||
else:
|
||||
# write results to JSON
|
||||
elif args.get('output_json'):
|
||||
write_csv(args['output_json'], PerfBdResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
# write results to CSV
|
||||
elif args.get('output'):
|
||||
write_csv(args['output'], PerfBdResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
# print table
|
||||
else:
|
||||
table(PerfBdResult, results, diff_results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
@@ -1621,10 +1619,6 @@ if __name__ == "__main__":
|
||||
'-v', '--verbose',
|
||||
action='store_true',
|
||||
help="Output commands that run behind the scenes.")
|
||||
parser.add_argument(
|
||||
'-q', '--quiet',
|
||||
action='store_true',
|
||||
help="Don't show anything, useful with -o.")
|
||||
parser.add_argument(
|
||||
'-o', '--output',
|
||||
help="Specify CSV file to store results.")
|
||||
|
||||
@@ -1053,20 +1053,6 @@ def main(ci_paths,
|
||||
depth=depth,
|
||||
hot=hot)
|
||||
|
||||
# write results to CSV/JSON
|
||||
if args.get('output'):
|
||||
write_csv(args['output'], StackResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], StackResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
|
||||
# find previous results?
|
||||
diff_results = None
|
||||
if args.get('diff') or args.get('percent'):
|
||||
@@ -1091,8 +1077,22 @@ def main(ci_paths,
|
||||
depth=depth,
|
||||
hot=hot)
|
||||
|
||||
# write results to JSON
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], StackResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
# write results to CSV
|
||||
elif args.get('output'):
|
||||
write_csv(args['output'], StackResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
# print table
|
||||
if not args.get('quiet'):
|
||||
else:
|
||||
table(StackResult, results, diff_results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
@@ -1121,10 +1121,6 @@ if __name__ == "__main__":
|
||||
'-v', '--verbose',
|
||||
action='store_true',
|
||||
help="Output commands that run behind the scenes.")
|
||||
parser.add_argument(
|
||||
'-q', '--quiet',
|
||||
action='store_true',
|
||||
help="Don't show anything, useful with -o.")
|
||||
parser.add_argument(
|
||||
'-o', '--output',
|
||||
help="Specify CSV file to store results.")
|
||||
|
||||
@@ -1088,10 +1088,12 @@ def main(obj_paths, *,
|
||||
else:
|
||||
by = ['struct']
|
||||
|
||||
visible = None
|
||||
if fields is None:
|
||||
if (args.get('output')
|
||||
or args.get('output_json')):
|
||||
fields = ['off', 'size', 'align']
|
||||
visible = ['size', 'align']
|
||||
else:
|
||||
fields = ['size', 'align']
|
||||
|
||||
# figure out depth
|
||||
if depth is None:
|
||||
@@ -1129,20 +1131,6 @@ def main(obj_paths, *,
|
||||
depth=depth,
|
||||
hot=hot)
|
||||
|
||||
# write results to CSV/JSON
|
||||
if args.get('output'):
|
||||
write_csv(args['output'], StructResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], StructResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
|
||||
# find previous results?
|
||||
diff_results = None
|
||||
if args.get('diff') or args.get('percent'):
|
||||
@@ -1167,11 +1155,25 @@ def main(obj_paths, *,
|
||||
depth=depth,
|
||||
hot=hot)
|
||||
|
||||
# write results to JSON
|
||||
if args.get('output_json'):
|
||||
write_csv(args['output_json'], StructResult, results, json=True,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
# write results to CSV
|
||||
elif args.get('output'):
|
||||
write_csv(args['output'], StructResult, results,
|
||||
by=by,
|
||||
fields=fields,
|
||||
depth=depth,
|
||||
**args)
|
||||
# print table
|
||||
if not args.get('quiet'):
|
||||
else:
|
||||
table(StructResult, results, diff_results,
|
||||
by=by,
|
||||
fields=visible if visible is not None else fields,
|
||||
fields=fields,
|
||||
sort=sort,
|
||||
labels=labels,
|
||||
depth=depth,
|
||||
@@ -1192,10 +1194,6 @@ if __name__ == "__main__":
|
||||
'-v', '--verbose',
|
||||
action='store_true',
|
||||
help="Output commands that run behind the scenes.")
|
||||
parser.add_argument(
|
||||
'-q', '--quiet',
|
||||
action='store_true',
|
||||
help="Don't show anything, useful with -o.")
|
||||
parser.add_argument(
|
||||
'-o', '--output',
|
||||
help="Specify CSV file to store results.")
|
||||
|
||||
Reference in New Issue
Block a user