Newer
Older
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
import enum, sys
import numpy as np
import matplotlib.pyplot as plt
class PlotName(enum.Enum):
DEVICE_DRIVER_OPENCONFIG = 'dev-drv-openconfig'
SERVICE_HANDLER_OPENCONFIG_L2NM = 'srv-hlr-openconfig-l2nm'
SERVICE_HANDLER_OPENCONFIG_L3NM = 'srv-hlr-openconfig-l3nm'
plot_name = PlotName.__members__.get(sys.argv[1])
if plot_name is None: raise Exception('Unsupported plot: {:s}'.format(str(plot_name)))
PLOTS = {
PlotName.DEVICE_DRIVER_OPENCONFIG: (
'Device Driver - OpenConfig', '0.0001-100', [
#('GetConfig', [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,121,0,0,0,0]),
#('SetConfig', [127,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,43,19,0,0,0,0,0,0]),
#('DeleteConfig', [92,1,0,0,0,0,0,0,0,0,0,0,0,0,5,2,8,71,14,0,0,0,0,0,0,0]),
('GetConfig', [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,121,0,0,0,0]),
('SetConfig', [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,43,19,0,0,0,0,0,0]),
('DeleteConfig', [0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,2,8,71,14,0,0,0,0,0,0,0]),
]),
PlotName.SERVICE_HANDLER_OPENCONFIG_L2NM: (
'Service Handler - L2NM OpenConfig', '0.001-100', [
('SetEndpoint', [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,10]),
('DeleteEndpoint', [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14]),
]),
PlotName.SERVICE_HANDLER_OPENCONFIG_L3NM: (
'Service Handler - L3NM OpenConfig', '0.001-100', [
('SetEndpoint', [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,17]),
('DeleteEndpoint', [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20]),
]),
}
BINS_RANGES = {
'0.0001-100' : [0, 0.0001, 0.00025, 0.0005, 0.00075, 0.001, 0.0025, 0.005, 0.0075,
0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10,
25, 50, 75, 100, 200],
'0.1-10' : [0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10],
'0.0001-1' : [0, 0.0001, 0.00025, 0.0005, 0.00075, 0.001, 0.0025, 0.005, 0.0075,
0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1],
'0.0001-0.25' : [0, 0.0001, 0.00025, 0.0005, 0.00075, 0.001, 0.0025, 0.005, 0.0075,
0.01, 0.025, 0.05, 0.075, 0.1, 0.25],
'1-100' : [1, 2.5, 5, 7.5, 10, 25, 50, 75, 100],
'0.001-100' : [0, 0.001, 0.0025, 0.005, 0.0075, 0.01, 0.025, 0.05, 0.075,
0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10, 25, 50, 75, 100, 200],
'0.001-7.5' : [0, 0.001, 0.0025, 0.005, 0.0075, 0.01, 0.025, 0.05, 0.075,
0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10],
'0.01-5' : [0, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5],
}
# plot the cumulative histogram
fig, ax = plt.subplots(figsize=(8, 8))
bins = PLOTS[plot_name][1]
if isinstance(bins, str): bins = BINS_RANGES[PLOTS[plot_name][1]]
bins = np.array(bins).astype(float)
for label, counts in PLOTS[plot_name][2]:
counts = np.array(counts).astype(float)
assert len(bins) == len(counts) + 1
centroids = (bins[1:] + bins[:-1]) / 2
ax.hist(centroids, bins=bins, weights=counts, range=(min(bins), max(bins)), density=True,
histtype='step', cumulative=True, label=label)
ax.grid(True)
ax.legend(loc='upper left')
ax.set_title(PLOTS[plot_name][0])
ax.set_xlabel('seconds')
ax.set_ylabel('Likelihood of occurrence')
plt.xscale('log')
plt.savefig('{:s}.png'.format(plot_name.value), dpi = (600))
plt.show()