Loading...
Searching...
No Matches
calculate_result.py
Go to the documentation of this file.
1
# Licensed to the Apache Software Foundation (ASF) under one
2
# or more contributor license agreements. See the NOTICE file
3
# distributed with this work for additional information
4
# regarding copyright ownership. The ASF licenses this file
5
# to you under the Apache License, Version 2.0 (the
6
# "License"); you may not use this file except in compliance
7
# with the License. You may obtain a copy of the License at
8
#
9
# http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing,
12
# software distributed under the License is distributed on an
13
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
# KIND, either express or implied. See the License for the
15
# specific language governing permissions and limitations
16
# under the License.
17
18
import
sys
19
20
def
read_tps
(file):
21
tps = []
22
lat = []
23
with
open(file)
as
f:
24
for
l
in
f.readlines():
25
s = l.split()
26
for
r
in
s:
27
if(r.split(
':'
)[0] ==
'txn'
):
28
tps.append(int(r.split(
':'
)[1]))
29
if
l.find(
"client latency"
) > 0:
30
lat.append(float(s[-1].split(
':'
)[-1]))
31
return
tps, lat
32
33
def
cal_tps
(tps):
34
tps_sum = []
35
tps_max = 0
36
37
for
v
in
tps:
38
if
v == 0:
39
continue
40
tps_max = max(tps_max, v)
41
tps_sum.append(v)
42
43
print(
"max throughput:"
,tps_max)
44
print(
"average throughput:"
,sum(tps_sum)/len(tps_sum))
45
46
def
cal_lat
(lat):
47
lat_sum = []
48
lat_max = 0
49
for
v
in
lat:
50
if
v == 0:
51
continue
52
lat_max = max(lat_max, v)
53
lat_sum.append(v)
54
55
print(
"max latency:"
,lat_max)
56
print(
"average latency:"
,sum(lat_sum)/len(lat_sum))
57
58
if
__name__ ==
'__main__'
:
59
files = sys.argv[1:]
60
print(
"calculate results, number of nodes:"
,len(files))
61
62
63
tps = []
64
lat = []
65
for
f
in
files:
66
t, l=
read_tps
(f)
67
tps += t
68
lat += l
69
70
cal_tps
(tps)
71
cal_lat
(lat)
calculate_result.cal_lat
cal_lat(lat)
Definition
calculate_result.py:46
calculate_result.read_tps
read_tps(file)
Definition
calculate_result.py:20
calculate_result.cal_tps
cal_tps(tps)
Definition
calculate_result.py:33
scripts
deploy
performance
calculate_result.py
Generated by
1.9.8