diff --git a/util/analyze/lib/block_stats.py b/util/analyze/lib/block_stats.py index 56ab7089e..cfbc38147 100755 --- a/util/analyze/lib/block_stats.py +++ b/util/analyze/lib/block_stats.py @@ -88,4 +88,4 @@ def compute_block_stats(logs: Logs): results = utils.foreach_bench(compute_block_stats, args.logs) - args.format(result) + args.format(results) diff --git a/util/analyze/lib/func_stats.py b/util/analyze/lib/func_stats.py old mode 100644 new mode 100755 index 6802a6b00..e38a00fad --- a/util/analyze/lib/func_stats.py +++ b/util/analyze/lib/func_stats.py @@ -1,10 +1,12 @@ #!/usr/bin/env python3 +import argparse import re from itertools import chain from typing import Iterable, List -from analyze import Block +import analyze +from analyze import Block, ioutils, utils ''' Function-level stats (not Block, Logs, or Benchmark level) @@ -25,3 +27,27 @@ def function_occupancy_info(logs: Iterable[Block]) -> List[int]: def avg_occupancy(logs: Iterable[Block]) -> float: occ_info = function_occupancy_info(logs) return sum(occ_info) / len(occ_info) if occ_info else 0.0 + + +def raw_main(argv: List[str] = []): + parser = argparse.ArgumentParser( + description='Computes the block stats for the logs') + parser.add_argument('--stat', required=True, choices=('occ',), + help='Which stat to compute') + parser.add_argument('logs', help='The logs to analyze') + ioutils.add_output_format_arg(parser) + args = analyze.parse_args(parser, 'logs') + + STATS = { + 'occ': ('Average Occupancy', avg_occupancy), + } + label, f = STATS[args.stat] + + results = utils.foreach_bench(lambda bench: {label: f(bench)}, args.logs) + + args.format(results) + + +if __name__ == '__main__': + import sys + raw_main(sys.argv)