diff options
author | Alexandre Rames <alexandre.rames@linaro.org> | 2016-08-11 10:33:37 +0000 |
---|---|---|
committer | Linaro Android Code Review <android-review@review.linaro.org> | 2016-08-11 10:33:37 +0000 |
commit | 48bea13a6516c7b932a9e827a8435017412121e7 (patch) | |
tree | 4ee9c414a2c8338e2869574beee8cde0a9a5414a | |
parent | 9c53e75186c05783167ee955c9133b9f3445de5d (diff) | |
parent | 39358fa2d4ddab3cf6c00fb935da7914ff485bae (diff) | |
download | art-testing-48bea13a6516c7b932a9e827a8435017412121e7.tar.gz |
Merge "Introduce a tool to convert result JSON files to bm-plotter format."
-rw-r--r-- | README.md | 15 | ||||
-rwxr-xr-x | tools/bm-plotter/convert.py | 52 | ||||
-rw-r--r-- | tools/utils.py | 16 |
3 files changed, 82 insertions, 1 deletions
@@ -98,6 +98,21 @@ See `tools/compilation_statistics/run.py --help` and The `tools/perf` directory includes tools to profile the Java benchmarks on target and generate an html output. See `tools/perf/PERF.README` for details. +### bm-plotter + +This `convert.py` python script converts the `.json` output of `run.py` scripts +into the format required by +[bm-plotter](https://github.com/ARM-software/bm-plotter). +`bm-plotter` is a tool offering a graphical output representing results. +You can generate the result image for example with: + + ./run.py --target --iterations=10 --output-json=base.json + git checkout patch_1 + ./run.py --target --iterations=10 --output-json=patch_1.json + git checkout patch_2 + ./run.py --target --iterations=10 --output-json=patch_2.json + ./tools/bm-plotter/convert.py base.json patch_1.json patch_2.json > /tmp/bm_out + <path/to/bm-plotter>/plot /tmp/bm_out ## How to Write a Benchmark diff --git a/tools/bm-plotter/convert.py b/tools/bm-plotter/convert.py new file mode 100755 index 0000000..feda48d --- /dev/null +++ b/tools/bm-plotter/convert.py @@ -0,0 +1,52 @@ +#! /usr/bin/env python3 + +# Copyright (C) 2016 Linaro Limited. All rights received. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import json +import os +import sys + +from collections import OrderedDict + +dir_bm_plotter = os.path.dirname(os.path.realpath(__file__)) +dir_tools = os.path.join(dir_bm_plotter, '..') +sys.path.insert(0, dir_tools) +import utils + +def BuildOptions(): + parser = argparse.ArgumentParser( + description = '''Convert output JSON files to bm-plotter format. The + output should fed to bm-plotter: + https://github.com/ARM-software/bm-plotter. See `README.md` for + examples''', + # Print default values. + formatter_class = argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument('json_files', nargs='+') + return parser.parse_args() + +if __name__ == "__main__": + args = BuildOptions() + + csv_data = [['Column', 'Set', 'Benchmark', 'Result']] + + for json_file in args.json_files: + with open(json_file, 'r') as result_file: + data = json.load(result_file, object_pairs_hook=OrderedDict) + data = utils.Flatten(data) + for bench in data: + for value in data[bench]: + print(','.join(['column', json_file, bench, str(value)])) + diff --git a/tools/utils.py b/tools/utils.py index e9aec1d..46bb743 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -373,7 +373,7 @@ def UnflattenHelper(res, key_list, value): def Unflatten(data, separator='/'): if isinstance(data, list): return data - elif not isinstance(data, dict) and not isinstance(data, OrderedDict): + elif not IsDictionary(data): Error("Unexpected data type: %s." % type(data)) res = OrderedDict() @@ -381,6 +381,20 @@ def Unflatten(data, separator='/'): UnflattenHelper(res, k.split(separator), Unflatten(data[k], separator)) return res +def Flatten(data, key=''): + if isinstance(data, list): + return {key: data} + elif not IsDictionary(data): + Error("Unexpected data type: %s." % type(data)) + + res = OrderedDict() + for k, v in data.items(): + new_key = key + '/' + k + res.update(Flatten(v, new_key)) + + return res + + def HaveSameKeys(data_1, data_2): if IsDictionary(data_1) and IsDictionary(data_2): |