1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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))
|