source: benchmark/process-mutilate.py @ c4b10e2

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

process mutilate now recors average latency

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