diff options
author | Zhizhou Yang <zhizhouy@google.com> | 2017-07-12 15:10:53 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-07-18 18:03:25 -0700 |
commit | 4af2cd8c1c4708b901c6c74c414ecba234e2b888 (patch) | |
tree | b9c0d670aa3508e3466810c9f085bfc2f7372864 /android_bench_suite/parse_result.py | |
parent | c600e4e6f2ffc7459a3a56b0bcb3d3f6842b4fbe (diff) | |
download | toolchain-utils-4af2cd8c1c4708b901c6c74c414ecba234e2b888.tar.gz |
Add Android toolchain benchmark suite
Add Android toolchain benchmark suite into toolchain-utils, which will
be synced to Android Repository.
BUG=None
TEST=None
Change-Id: Iee1ba9aa21a99ff6ce8d669c59d53af6e953703c
Reviewed-on: https://chromium-review.googlesource.com/569481
Commit-Ready: Zhizhou Yang <zhizhouy@chromium.org>
Tested-by: Zhizhou Yang <zhizhouy@chromium.org>
Reviewed-by: Luis Lozano <llozano@chromium.org>
Diffstat (limited to 'android_bench_suite/parse_result.py')
-rw-r--r-- | android_bench_suite/parse_result.py | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/android_bench_suite/parse_result.py b/android_bench_suite/parse_result.py new file mode 100644 index 00000000..90b3c4d1 --- /dev/null +++ b/android_bench_suite/parse_result.py @@ -0,0 +1,114 @@ +# Copyright 2017 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +"""Helper functions to parse result collected from device""" + +from __future__ import print_function +from fix_skia_results import _TransformBenchmarks + +import json + +def normalize(bench, dict_list): + bench_base = { + 'Panorama': 1, + 'Dex2oat': 1, + 'Hwui': 10000, + 'Skia': 1, + 'Synthmark': 1, + 'Binder': 0.001 + } + result_dict = dict_list[0] + for key in result_dict: + result_dict[key] = result_dict[key] / bench_base[bench] + return [result_dict] + + +# Functions to parse benchmark result for data collection. +def parse_Panorama(bench, fin): + result_dict = {} + for line in fin: + words = line.split() + if 'elapsed' in words: + #TODO: Need to restructure the embedded word counts. + result_dict['total_time_s'] = float(words[3]) + result_dict['retval'] = 0 + return normalize(bench, [result_dict]) + raise ValueError('You passed the right type of thing, ' + 'but it didn\'t have the expected contents.') + + +def parse_Synthmark(bench, fin): + result_dict = {} + accum = 0 + cnt = 0 + for line in fin: + words = line.split() + if 'normalized' in words: + #TODO: Need to restructure the embedded word counts. + accum += float(words[-1]) + cnt += 1 + if accum != 0: + result_dict['total_voices'] = accum / cnt + result_dict['retval'] = 0 + return normalize(bench, [result_dict]) + raise ValueError('You passed the right type of thing, ' + 'but it didn\'t have the expected contents.') + + +def parse_Binder(bench, fin): + result_dict = {} + accum = 0 + cnt = 0 + for line in fin: + words = line.split() + for word in words: + if 'average' in word: + #TODO: Need to restructure the embedded word counts. + accum += float(word[8:-2]) + cnt += 1 + if accum != 0: + result_dict['avg_time_ms'] = accum / cnt + result_dict['retval'] = 0 + return normalize(bench, [result_dict]) + raise ValueError('You passed the right type of thing, ' + 'but it didn\'t have the expected contents.') + + +def parse_Dex2oat(bench, fin): + result_dict = {} + cnt = 0 + for line in fin: + words = line.split() + if 'elapsed' in words: + cnt += 1 + #TODO: Need to restructure the embedded word counts. + if cnt == 1: + # First 'elapsed' time is for microbench 'Chrome' + result_dict['chrome_s'] = float(words[3]) + elif cnt == 2: + # Second 'elapsed' time is for microbench 'Camera' + result_dict['camera_s'] = float(words[3]) + + result_dict['retval'] = 0 + # Two results found, return + return normalize(bench, [result_dict]) + raise ValueError('You passed the right type of thing, ' + 'but it didn\'t have the expected contents.') + + +def parse_Hwui(bench, fin): + result_dict = {} + for line in fin: + words = line.split() + if 'elapsed' in words: + #TODO: Need to restructure the embedded word counts. + result_dict['total_time_s'] = float(words[3]) + result_dict['retval'] = 0 + return normalize(bench, [result_dict]) + raise ValueError('You passed the right type of thing, ' + 'but it didn\'t have the expected contents.') + + +def parse_Skia(bench, fin): + obj = json.load(fin) + return normalize(bench, _TransformBenchmarks(obj)) |