-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_iperf.py
155 lines (133 loc) · 4.74 KB
/
plot_iperf.py
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
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
import argparse
import seaborn as sns
import pandas as pd
from re import search, findall, MULTILINE
from os.path import basename, getsize
from typing import List
COLORS = mcolors.CSS4_COLORS.keys()
# COLORS = [
# 'blue',
# 'cyan',
# 'green',
# 'yellow',
# 'orange',
# 'red',
# 'magenta',
# ]
hue_map = {
'3_bridge-e1000_forwardbackward': 'qemu-e1000',
'3_bridge_forwardbackward': 'qemu-virtio',
'3_bridge-vhost_forwardbackward': 'qemu-vhost',
'3_vfio_forwardbackward': 'qemu-vfio',
'3_vmux-dpdk-e810_forwardbackward': 'vmux-e810-emu-dpdk',
'3_vmux-dpdk_forwardbackward': 'vmux-e1000-dpdk',
'3_vmux-emu_forwardbackward': 'vmux-e810-emu',
'3_vmux-med_forwardbackward': 'vmux-e810-med',
}
YLABEL = 'Per-VM Throughput (GBit/s)'
XLABEL = 'Num. of VMs'
def map_hue(df_hue, hue_map):
return df_hue.apply(lambda row: hue_map.get(str(row), row))
def setup_parser():
parser = argparse.ArgumentParser(
description='Plot packet loss graph'
)
parser.add_argument('-t',
'--title',
type=str,
help='Title of the plot',
)
parser.add_argument('-W', '--width',
type=float,
default=12,
help='Width of the plot in inches'
)
parser.add_argument('-H', '--height',
type=float,
default=6,
help='Height of the plot in inches'
)
parser.add_argument('-o', '--output',
type=argparse.FileType('w+'),
help='''Path to the output plot
(default: packet_loss.pdf)''',
default='iperf.pdf'
)
parser.add_argument('-l', '--logarithmic',
action='store_true',
help='Plot logarithmic latency axis',
)
for color in COLORS:
parser.add_argument(f'--{color}',
type=argparse.FileType('r'),
nargs='+',
help=f'''Paths to MoonGen measurement logs for
the {color} plot''',
)
for color in COLORS:
parser.add_argument(f'--{color}-name',
type=str,
default=color,
help=f'''Name of {color} plot''',
)
return parser
def parse_args(parser):
args = parser.parse_args()
if not any([args.__dict__[color] for color in COLORS]):
parser.error('At least one set of moongen log paths must be ' +
'provided')
return args
def main():
parser = setup_parser()
args = parse_args(parser)
fig = plt.figure(figsize=(args.width, args.height))
ax = fig.add_subplot(1, 1, 1)
ax.set_axisbelow(True)
if args.title:
plt.title(args.title)
plt.grid()
# plt.xlim(0, 0.83)
ax.set_yscale('log' if args.logarithmic else 'linear')
dfs = []
for color in COLORS:
if args.__dict__[color]:
dfs += [ pd.read_csv(f.name, sep='\\s+') for f in args.__dict__[color] ]
# throughput = ThroughputDatapoint(
# moongen_log_filepaths=[f.name for f in args.__dict__[color]],
# name=args.__dict__[f'{color}_name'],
# color=color,
# )
# dfs += color_dfs
df = pd.concat(dfs)
# hue = ['repetitions', 'num_vms', 'interface', 'direction']
# groups = df.groupby(hue)
# summary = df.groupby(hue)['rxMppsCalc'].describe()
df_hue = df.apply(lambda row: '_'.join(str(row[col]) for col in ['repetitions', 'interface', 'direction']), axis=1)
df_hue = map_hue(df_hue, hue_map)
# Plot using Seaborn
sns.catplot(x='length', y='GBit/s', hue=df_hue, data=pd.concat(dfs), palette='colorblind', kind='point',
capsize=.05, # errorbar='sd'
)
# sns.move_legend(
# ax, "lower center",
# bbox_to_anchor=(.5, 1), ncol=3, title=None, frameon=False,
# )
#
plt.xlabel(XLABEL)
plt.ylabel(YLABEL)
plt.ylim(bottom=0)
# plt.ylim(0, 5)
# for container in ax.containers:
# ax.bar_label(container, fmt='%.0f')
# legend = plt.legend()
# legend.get_frame().set_facecolor('white')
# legend.get_frame().set_alpha(0.8)
fig.tight_layout()
plt.savefig(args.output.name)
plt.close()
if __name__ == '__main__':
main()