From 4fb11202806783f46d573f83f4326e9a68a46707 Mon Sep 17 00:00:00 2001 From: Benjamin Blanc <benjamin.blanc@tiolive.com> Date: Fri, 13 Sep 2013 11:41:09 +0200 Subject: [PATCH] performance_tester: add command line options to use different paths. Add option to specify several path where to find users file(s), and benchmark suite file(s). --- erp5/util/benchmark/argument.py | 6 +++++- erp5/util/benchmark/performance_tester.py | 26 ++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/erp5/util/benchmark/argument.py b/erp5/util/benchmark/argument.py index 3768d75141..39feeaf2fe 100644 --- a/erp5/util/benchmark/argument.py +++ b/erp5/util/benchmark/argument.py @@ -41,7 +41,7 @@ class ArgumentType(object): @classmethod def objectFromModule(cls, module_name, object_name=None, - callable_object=False): + callable_object=False, searchable_path_list=None): if module_name.endswith('.py'): module_name = module_name[:-3] @@ -50,6 +50,10 @@ class ArgumentType(object): import sys sys.path.append(os.getcwd()) + + if searchable_path_list: + for path in searchable_path_list: + sys.path.append(path) try: module = __import__(module_name, globals(), locals(), [object_name], -1) diff --git a/erp5/util/benchmark/performance_tester.py b/erp5/util/benchmark/performance_tester.py index bcda842999..45f2a2dc0c 100755 --- a/erp5/util/benchmark/performance_tester.py +++ b/erp5/util/benchmark/performance_tester.py @@ -77,6 +77,10 @@ class PerformanceTester(object): metavar='MODULE', help="Import users from ``user_tuple'' in MODULE") + parser.add_argument('--users-file-path', + metavar='USER_FILE_PATH', + help='User file path') + parser.add_argument('--users-range-increment', type=ArgumentType.checkIntValueWrapper(minimum=1), default=1, @@ -132,6 +136,13 @@ class PerformanceTester(object): metavar='ERP5_PUBLISH_PROJECT', help='ERP5 publish project') + + parser.add_argument('--benchmark-path-list', + default=[], + nargs='+', + metavar='BENCHMARK_PATH', + help='Benchmark paths') + # Mandatory arguments parser.add_argument('erp5_base_url', metavar='ERP5_URL') @@ -144,16 +155,25 @@ class PerformanceTester(object): nargs='+', metavar='BENCHMARK_SUITES', help='Benchmark suite modules') + @staticmethod def _check_parsed_arguments(namespace): + if namespace.users_file_path: + users_file_path_list = [namespace.users_file_path] + else: + users_file_path_list = [] namespace.user_tuple = ArgumentType.objectFromModule(namespace.user_info_filename, - object_name='user_tuple') - + object_name='user_tuple', + searchable_path_list=users_file_path_list) + + namespace.benchmark_suite_list = namespace.benchmark_suite_list[0].split(" ") + object_benchmark_suite_list = [] for benchmark_suite in namespace.benchmark_suite_list: object_benchmark_suite_list.append(ArgumentType.objectFromModule(benchmark_suite, - callable_object=True)) + callable_object=True, + searchable_path_list=namespace.benchmark_path_list)) if namespace.repeat > 0: namespace.max_error_number = \ -- 2.30.9