From 50c66a1a4f40f069fb3706602025f53952c5cc33 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 30 May 2020 12:48:27 +0200 Subject: [benchmark.py] add function to retrieve Benchmark instance from a module --- bench.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'bench.py') diff --git a/bench.py b/bench.py index 007dbe9..adecc89 100755 --- a/bench.py +++ b/bench.py @@ -21,13 +21,13 @@ import argparse import atexit import datetime -import importlib import os import sys import traceback from allocbench.allocator import collect_allocators from allocbench.analyse import analyze_bench, analyze_allocators +from allocbench.benchmark import get_benchmark_object import allocbench.facter as facter import allocbench.globalvars from allocbench.util import run_cmd @@ -173,15 +173,13 @@ def main(): if args.exclude_benchmarks and bench in args.exclude_benchmarks: continue - bench_module = importlib.import_module( - f"allocbench.benchmarks.{bench}") - - # find Benchmark class - for member in bench_module.__dict__.values(): - if (not isinstance(member, type) - or member is allocbench.benchmark.Benchmark - or not issubclass(member, allocbench.benchmark.Benchmark)): - continue + try: + print_status("Loading", bench, "...") + bench = get_benchmark_object(bench) + except Exception: + print_error(traceback.format_exc()) + print_error(f"Skipping {bench}! Loading failed.") + continue try: print_status("Preparing", bench, "...") -- cgit v1.2.3