diff --git a/bench.py b/bench.py index ed5b2da274019a00f42d46a6943ecae441d5c67c..852bb72fec03ca3175cbe6610dc6cc8a9d19837e 100755 --- a/bench.py +++ b/bench.py @@ -34,6 +34,8 @@ from src.util import print_status, print_warn, print_error from src.util import print_info, print_info2, print_debug from src.util import print_license_and_exit +from summarize import summarize + def epilog(): """Run tasks on exit""" @@ -81,10 +83,7 @@ def main(): help="how often the benchmarks run", default=3, type=int) - parser.add_argument("-v", - "--verbose", - help="more output", - action='count') + parser.add_argument("-v", "--verbose", help="more output", action='count') parser.add_argument("-b", "--benchmarks", help="benchmarks to run", @@ -103,6 +102,10 @@ def main(): "--resultdir", help="directory where all results go", type=str) + parser.add_argument("-s", + "--summarize", + help="create a summary of this run", + action='store_true') parser.add_argument("--license", help="print license info and exit", action='store_true') @@ -256,6 +259,9 @@ def main(): print_status("Cleaning up", bench.name, "...") bench.cleanup() + if args.summarize: + summarize() + if __name__ == "__main__": main() diff --git a/summarize.py b/summarize.py index 351bedf3e60a92fd7eae0663148de8d436a098dc..5eed1a1bb00ddca52c5da31875ff451883bc4d66 100755 --- a/summarize.py +++ b/summarize.py @@ -90,41 +90,16 @@ def bench_sum(bench): os.chdir("..") -def main(): - if "--license" in sys.argv: - print_license_and_exit() +def summarize(benchmarks=None, exclude_benchmarks=None): + """summarize the benchmarks in the resdir""" - if "--version" in sys.argv: - print(src.facter.allocbench_version()) - sys.exit(0) - - parser = argparse.ArgumentParser(description="Summarize allocbench results in allocator sets") - parser.add_argument("results", help="path to results", type=str) - parser.add_argument("-t", "--file-ext", help="file extension used for plots", type=str) - parser.add_argument("--license", help="print license info and exit", action='store_true') - parser.add_argument("--version", help="print version info and exit", action='store_true') - parser.add_argument("-b", "--benchmarks", help="benchmarks to summarize", nargs='+') - parser.add_argument("-x", "--exclude-benchmarks", help="benchmarks to exclude", nargs='+') - - args = parser.parse_args() - - if not os.path.isdir(args.results): - print_error(f"{args.results} is no directory") - sys.exit(1) - - if args.file_ext: - src.globalvars.summary_file_ext = args.file_ext - - src.globalvars.resdir = args.results - os.chdir(args.results) - - # Load facts - src.facter.load_facts() + cwd = os.getcwd() + os.chdir(src.globalvars.resdir) for benchmark in src.globalvars.benchmarks: - if args.benchmarks and not benchmark in args.benchmarks: + if benchmarks and not benchmark in benchmarks: continue - if args.exclude_benchmarks and benchmark in args.exclude_benchmarks: + if exclude_benchmarks and benchmark in exclude_benchmarks: continue bench_module = importlib.import_module(f"src.benchmarks.{benchmark}") @@ -146,6 +121,36 @@ def main(): except FileExistsError as e: print(e) + os.chdir(cwd) if __name__ == "__main__": - main() + if "--license" in sys.argv: + print_license_and_exit() + + if "--version" in sys.argv: + print(src.facter.allocbench_version()) + sys.exit(0) + + parser = argparse.ArgumentParser(description="Summarize allocbench results in allocator sets") + parser.add_argument("results", help="path to results", type=str) + parser.add_argument("-t", "--file-ext", help="file extension used for plots", type=str) + parser.add_argument("--license", help="print license info and exit", action='store_true') + parser.add_argument("--version", help="print version info and exit", action='store_true') + parser.add_argument("-b", "--benchmarks", help="benchmarks to summarize", nargs='+') + parser.add_argument("-x", "--exclude-benchmarks", help="benchmarks to exclude", nargs='+') + + args = parser.parse_args() + + if args.file_ext: + src.globalvars.summary_file_ext = args.file_ext + + if not os.path.isdir(args.results): + print_error(f"{args.results} is no directory") + sys.exit(1) + + src.globalvars.resdir = args.results + + # Load facts + src.facter.load_facts(src.globalvars.resdir) + + summarize(benchmarks=args.benchmarks, exclude_benchmarks=args.exclude_benchmarks)