diff options
author | wu.zhihui <wu.zhihui1@zte.com.cn> | 2016-10-12 15:32:52 +0800 |
---|---|---|
committer | wu.zhihui <wu.zhihui1@zte.com.cn> | 2016-10-14 17:16:00 +0800 |
commit | eddc35b497362c0c01e612d66ed19c4d5c9dd328 (patch) | |
tree | 9a9c792a002fce40782158b9d645e597d3606f1b /scripts/ref_results/suite_result.py | |
parent | 975e241de4d4bf3839c788ad743d0cc077e23bd4 (diff) |
Adjust directory structure
qtip
!
+---- scripts
! !
! +----ref_result # python scripts to generate results report
! +----fetch_compute_ips.sh
! +----fetch_os_creds.sh
! +----file_permission.sh
! +----get_env_info.sh
! +----qtip_creds.sh
! +----ssh_exch.exp
!
+---- config
! !
! +---- Qtip_key
! +---- Qtip_key.pub
! +---- SampleHeat.yaml
!
+---- utils
! !
! +---- logger_utils.py
! +---- report # generate pdf report file
Change-Id: Ia908ff31494369c1a13fb88b1ff9b0e5681f8e29
Signed-off-by: wu.zhihui <wu.zhihui1@zte.com.cn>
Diffstat (limited to 'scripts/ref_results/suite_result.py')
-rw-r--r-- | scripts/ref_results/suite_result.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/ref_results/suite_result.py b/scripts/ref_results/suite_result.py new file mode 100644 index 00000000..d0b4647f --- /dev/null +++ b/scripts/ref_results/suite_result.py @@ -0,0 +1,55 @@ +############################################################################## +# Copyright (c) 2016 ZTE Corp and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +import json +import importlib +import sys +from utils import logger_utils + +logger = logger_utils.QtipLogger('suite_result').get + + +def get_benchmark_result(benchmark_name, suite_name): + benchmark_indices = importlib.import_module('{0}_benchmarks_indices'.format(suite_name)) + methodToCall = getattr(benchmark_indices, '{0}_index'.format(benchmark_name)) + return methodToCall() + + +def get_suite_result(suite_name): + suite_dict = {} + suite_bench_list = {'compute': ['DPI', 'Dhrystone', 'Whetstone', 'SSL', 'RamSpeed'], + 'storage': ['FIO'], + 'network': ['IPERF']} + temp = 0 + l = len(suite_bench_list[suite_name]) + for benchmark in suite_bench_list[suite_name]: + try: + suite_dict[benchmark] = get_benchmark_result(benchmark.lower(), suite_name) + temp = temp + float(suite_dict[benchmark]['index']) + except OSError: + l = l - 1 + pass + + if l == 0: + logger.info("No {0} suite results found".format(suite_name)) + return False + else: + suite_index = temp / l + suite_dict_f = {'index': suite_index, + 'suite_results': suite_dict} + with open('results/{0}_result.json'.format(suite_name), 'w+') as result_json: + json.dump(suite_dict_f, result_json, indent=4, sort_keys=True) + return True + + +def main(): + get_suite_result(sys.argv[1]) + + +if __name__ == "__main__": + main() |