Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1078)

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/test/plot_dynamics.py

Issue 1237903003: Modified histogram shell plot script, added python dynamics plot script (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Split bwe_plot.sh, comments addressed Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 #
4 # Use of this source code is governed by a BSD-style license
5 # that can be found in the LICENSE file in the root of the source
6 # tree. An additional intellectual property rights grant can be found
7 # in the file PATENTS. All contributing project authors may
8 # be found in the AUTHORS file in the root of the source tree.
9
10 # This script is used to plot simulation dynamics.
11 # Able to plot each flow separately. Other plot boxes can be added,
12 # currently one for Throughput, one for Latency and one for Packet Loss.
13
14 import matplotlib
15 import matplotlib.pyplot as plt
16 import math
17 import numpy
18 import re
19 import sys
20
21
22 class Variable:
23 def __init__(self, variable):
24 self._ID = variable[0]
25 self._xlabel = variable[1]
26 self._ylabel = variable[2]
27 self._subplot = variable[3]
28 self._y_max = variable[4]
29 self._samples = dict()
30
31 def getID(self):
32 return self._ID
33
34 def getXLabel(self):
35 return self._xlabel
36
37 def getYLabel(self):
38 return self._ylabel
39
40 def getSubplot(self):
41 return self._subplot
42
43 def getYMax(self):
44 return self._y_max
45
46 def getNumberOfFlows(self):
47 return len(self._samples)
48
49
50 def addSample(self, line):
51 groups = re.search(r'/\d_(\w+)#\d@(\w*)', line)
52 var_name = groups.group(1)
53 alg_name = groups.group(2)
54
55 if alg_name not in self._samples.keys():
56 self._samples[alg_name] = {}
57
58 if var_name not in self._samples[alg_name].keys():
59 self._samples[alg_name][var_name] = []
60
61 sample = re.search(r'(\d+\.\d+)\t([-]?\d+\.\d+)', line)
62 s = (sample.group(1),sample.group(2))
63 self._samples[alg_name][var_name].append(s)
64
65 def plotVar(v, ax, show_legend, show_x_label):
66 if show_x_label:
67 ax.set_xlabel(v.getXLabel(), fontsize='large')
68 ax.set_ylabel(v.getYLabel(), fontsize='large')
69
70 for alg in v._samples.keys():
71 i = 1
72 for series in v._samples[alg].keys():
73 x = [sample[0] for sample in v._samples[alg][series]]
74 y = [sample[1] for sample in v._samples[alg][series]]
75 x = numpy.array(x)
76 y = numpy.array(y)
77 line = plt.plot(x, y, label=alg, linewidth=4.0)
78 colormap = {'Available1':'#AAAAAA',
79 'Available2':'#AAAAAA',
80 'GCC1':'#80D000',
81 'GCC2':'#008000',
82 'GCC3':'#00F000',
83 'GCC4':'#00B000',
84 'GCC5':'#70B020',
85 'NADA1':'#0000AA',
86 'NADA2':'#A0A0FF',
87 'NADA3':'#0000FF',
88 'NADA4':'#C0A0FF',
89 'NADA5':'#9060B0',
90 'TCP1':'#AAAAAA',
91 'TCP2':'#AAAAAA',
92 'TCP3':'#AAAAAA',
93 'TCP4':'#AAAAAA',
94 'TCP5':'#AAAAAA',
95 'TCP6':'#AAAAAA',
96 'TCP7':'#AAAAAA',
97 'TCP8':'#AAAAAA',
98 'TCP9':'#AAAAAA',
99 'TCP10':'#AAAAAA',}
100
101 plt.setp(line, color=colormap[alg + str(i)])
102 if alg.startswith('Available'):
103 plt.setp(line, linestyle='--')
104 plt.grid(True)
105
106 x1, x2, y1, y2 = plt.axis()
107 if v.getYMax() >= 0:
108 y2 = v.getYMax()
109 plt.axis((0, x2, 0, y2))
110 i += 1
111
112 if show_legend:
113 legend = plt.legend(loc='upper right', shadow=True, fontsize='large', ncol =len(v._samples))
stefan-webrtc 2015/07/22 09:32:03 Can you make this line 80 characters?
magalhaesc 2015/07/22 12:54:41 Done.
114
115 if __name__ == '__main__':
116
117 variables = [
118 ('Throughput_kbps', "Time (s)", "Throughput (kbps)", 1, 4000),
119 ('Delay_ms', "Time (s)", "One-way Delay (ms)", 2, 500),
120 ('Packet_Loss', "Time (s)", "Packet Loss Ratio", 3, 1.0),
121 ]
122
123 var = []
124
125 # Create objects.
126 for variable in variables:
127 var.append(Variable(variable))
128
129 # Add samples to the objects.
130 for line in sys.stdin:
131 if line.startswith("[ RUN ]"):
132 test_name = re.search('\.(\w+)', line).group(1)
133 if line.startswith("PLOT"):
134 for v in var:
135 if v.getID() in line:
136 v.addSample(line)
137
138 matplotlib.rcParams.update({'font.size': 20})
139
140 # Plot variables.
141 fig = plt.figure()
142
143 # Offest and threshold on the same plot.
144 n = var[-1].getSubplot()
145 i = 0
146 for v in var:
147 ax = fig.add_subplot(n, 1, v.getSubplot())
148 plotVar(v, ax, i == 0, i == n - 1)
149 i += 1
150
151 #fig.savefig(test_name+".jpg")
152 plt.show()
153
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698