forked from markseger/getput
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpsum
executable file
·212 lines (170 loc) · 6.42 KB
/
gpsum
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/usr/bin/python3 -u
# Copyright 2016 Hewlett-Packard Development Company, L.P.
# Use of this script is subject to HP Terms of Use at
# http://www8.hp.com/us/en/privacy/terms-of-use.html.
# 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 re
import sys
from optparse import OptionParser, OptionGroup
def error(text):
print(text)
sys.exit()
def main(argv):
global options
parser = OptionParser()
parser.add_option('-c', dest='col', help='column to summarize [cilr]', default='r')
parser.add_option('-f', dest='file', help='file containing test data', default='')
parser.add_option('-v', dest='vertical', help='vertical output', action='store_true')
try:
(options, args) = parser.parse_args(argv)
except:
error('invalid option')
if options.file == '':
error('-f required')
try:
file = open(options.file, 'r')
except:
error("Couldn't open %s" % options.file)
data = {}
obj_sizes = {}
num_threads = {}
tests = {}
median = offset = 0
# assumes getput output w/o --ldist
gpshift = 1
for line in file:
if re.match("#gpsuite", line):
gpshift = 0
offset = 11
# ignore blank lines and comments
line = line[:-1]
if line == '' or re.match("^#", line):
continue
# ignore api errors
if re.search('API', line):
continue
fields = line.split()
test = fields[0 + gpshift]
# gotta do test this way because strings could be in gpsuite headers
if test == 'put' or test == 'get' or test == 'del' or re.match('[pg]\d+', test):
if test == 'put':
tname = '1' + test
elif test == 'get':
tname = '2' + test
elif test == 'del':
tname = '3' + test
elif re.match('p\d+g\d+', test):
tname = '4' + test
elif re.match('p\d+', test):
tname = '5' + test
elif re.match('g\d+', test):
tname = '6' + test
if tname not in tests:
tests[tname] = ''
clients = int(fields[1 + gpshift])
procs = int(fields[2 + gpshift])
osize = fields[3 + gpshift].lower()
match = re.match('(\d+)(\S)', osize)
if match:
osize = '%s%07d' % (match.group(2), int(match.group(1)))
threads = procs
key = '%s-%04d-%s' % (tname, threads, osize)
if not key in data:
data[key]={}
data[key]['rate'] = fields[6 + gpshift]
data[key]['iops'] = fields[8 + gpshift]
data[key]['lat'] = fields[10 + gpshift]
data[key]['range'] = fields[12 + gpshift]
data[key]['cpu'] = fields[13+gpshift+offset]
# remember all uniqe object sizes and thread counts so we can sort
obj_sizes[osize] = ''
num_threads['%04d' % threads] = '%s-%s' % (clients, procs)
numcols = len(obj_sizes)
if options.col == 'c':
col_name = '%CPU'
col_type = 'cpu'
elif options.col == 'i':
col_name = 'IOPS'
col_type = 'iops'
elif options.col == 'l':
col_name = 'Latency'
col_type = 'lat'
elif options.col == 'r':
col_name = 'MB/sec'
col_type = 'rate'
elif options.col == 'R':
col_name = 'LatRange'
col_type = 'range'
if options.vertical:
for tname in sorted(tests):
if tname not in tests:
continue
test = tname[1:]
# headers
print("Test: %s %s" % (test, col_name))
print('%4s %3s %3s ' % ('Totl', 'Clt', 'Prc'), end=' ')
for osize in sorted(obj_sizes):
size = str(int(osize[1:])) + osize[0]
print(' %7s' % size, end=' ')
print()
# print one line
for threads in sorted(num_threads):
clients, procs = num_threads[threads].split('-')
print('%4d %3s %3d ' % (int(procs), clients, int(procs) / int(clients)), end=' ')
for osize in sorted(obj_sizes):
key = '%s-%04s-%s' % (tname, threads, osize)
try:
value = data[key][col_type]
except KeyError:
value = '-'
print(' %7s' % value, end=' ')
print()
print()
else:
# headers
data_width = 9 * len(obj_sizes)
line = '*** %-4s ***' % col_name
for tname in sorted(tests):
if tname not in tests:
continue
test = tname[1:]
line += ' '
line += '{type:{width}}'.format(type=' *** %s ***' % test, width=data_width)
print(line)
line = '%4s %3s %3s ' % ('Totl', 'Clt', 'Prc')
for tname in sorted(tests):
if tname not in tests:
continue
test = tname[1:]
line += ' '
for osize in sorted(obj_sizes):
size = str(int(osize[1:])) + osize[0]
line += ' %8s' % size
print(line)
# data
for threads in sorted(num_threads):
clients, procs = num_threads[threads].split('-')
line = '%4d %3s %3d ' % (int(procs), clients, int(procs) / int(clients))
for tname in sorted(tests):
if tname not in tests:
continue
test = tname[1:]
line += ' '
for osize in sorted(obj_sizes):
key = '%s-%04s-%s' % (tname, threads, osize)
try:
value = data[key][col_type]
except KeyError:
value = '-'
line += ' %8s' % value
print(line)
if __name__ == "__main__":
main(sys.argv[1:])