source: benchmark/process-mutilate.py @ e9c5db2

ADTast-experimentalpthread-emulationqualifiedEnum
Last change on this file since e9c5db2 was e9c5db2, checked in by Thierry Delisle <tdelisle@…>, 2 years ago

Minor fixes to benchmark processing scripts

  • Property mode set to 100755
File size: 2.8 KB
Line 
1#!/usr/bin/python3
2"""
3Python Script to convert output from mutilate to rmit like output
4"""
5import argparse
6import json
7import locale
8import os
9import re
10import sys
11
12locale.setlocale( locale.LC_ALL, 'en_US.UTF-8' )
13
14parser = argparse.ArgumentParser(description='Python Script to convert output from mutilate to rmit like output')
15parser.add_argument('--out', nargs='?', type=argparse.FileType('w'), default=sys.stdout)
16try:
17        options =  parser.parse_args()
18except:
19        print('ERROR: invalid arguments', file=sys.stderr)
20        parser.print_help(sys.stderr)
21        sys.exit(1)
22
23thisdir = os.getcwd()
24dirs = os.listdir( thisdir )
25
26names = ['fibre', 'forall', 'vanilla']
27names_re = '|'.join(names)
28
29def precentile(line):
30        fields = line.split()
31
32        try:
33                lat50s = fields[6]
34                lat99s = fields[9]
35        except:
36                raise Warning("Warning: \"{}\"! insufficient fields".format(line))
37
38        try:
39                lat50 = locale.atof(lat50s)
40                lat99 = locale.atof(lat99s)
41        except:
42                raise Warning("Warning: \"{}\" \"{}\"! can't convert to float".format(lat50s, lat99s))
43
44        return lat50, lat99
45
46def want0(line):
47        line = line.strip()
48        if not line.endswith("= 0 (0.0%)"):
49                raise Warning("Warning: \"{}\"! should be 0".format(line))
50
51def extract(filename, out):
52        with open(filename, "r") as file:
53                lines = file.readlines()
54
55        warns = []
56
57        for line in lines:
58                try:
59                        if   line.startswith("read"):
60                                rlat50, rlat99 = precentile(line)
61
62                        elif line.startswith("update"):
63                                ulat50, ulat99 = precentile(line)
64
65                        elif line.startswith("Total QPS"):
66                                match = re.search("Total QPS = ([0-9,\.]+)", line)
67                                if match:
68                                        try:
69                                                qps = locale.atof(match[1])
70                                        except:
71                                                raise Warning("Warning: \"{}\" can't convert qps to float".format(match[1]))
72                                else:
73                                        raise Warning("Warning: \"{}\" line unreadable".format(line))
74
75                        if line.startswith("Misses") or line.startswith("Skipped TXs"):
76                                want0(line)
77                except Warning as w:
78                        warns.append(str(w))
79
80        try:
81                out['Actual QPS'] = qps
82        except:
83                warns.append("Warning: No total QPS")
84
85        try:
86                out['Median Read Latency'] = rlat50
87                out['Tail Read Latency'] = rlat99
88        except:
89                warns.append("Warning: no read latencies")
90
91        try:
92                out['Median Update Latency'] = ulat50
93                out['Tail Update Latency'] = ulat99
94        except:
95                warns.append("Warning: no update latencies")
96
97        return warns
98
99
100data = []
101
102for filename in dirs:
103        f = os.path.join( thisdir, filename )
104        # checking if it is a file
105        if os.path.isfile(f):
106                match = re.search("({})\.([0-9]+)\.([0-9]+)".format(names_re), filename)
107                try:
108                        series = match[1]
109                        rate = match[2]
110                        rep = match[3]
111                except:
112                        continue
113
114                d = { 'Target QPS': int(rate) }
115
116                w = extract( f, d )
117
118                data.append([series, "memcached {}".format(series), d])
119                if w:
120                        print("{} {} {}\n{}\n".format(series, rate, rep, '\n'.join(w)))
121
122options.out.write(json.dumps(data))
123options.out.flush()
124options.out.write("\n")
Note: See TracBrowser for help on using the repository browser.