Révision 308a0754

b/papers/2014/reservation/experiments/src/python/lib/kadeploy.py
7 7
import numpy as np
8 8
from matplotlib import rc
9 9
from pylab import *
10
from scipy.stats import gaussian_kde
10
from scipy.stats import gaussian_kde, lognorm, rayleigh, norm
11
import scipy.stats as stats
11 12
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
12 13
rc('text', usetex=True)
13 14
plt.rcParams.update({'font.size': 14})
......
20 21
    def __init__(self, host, start, step1_dur, step2_dur, step3_dur, success):
21 22
        self._host = host
22 23
        self._start = start
23
        self._step1_dur = step1_dur
24
        self._step2_dur = step2_dur
25
        self._step3_dur = step3_dur
24
        self._step1_dur = int(step1_dur)
25
        self._step2_dur = int(step2_dur)
26
        self._step3_dur = int(step3_dur)
26 27
        self._success = success
27 28
        self._retry_1 = 0
28 29
        self._retry_2 = 0
......
49 50
        return self._step3_dur
50 51

  
51 52
    @property
53
    def deployment_duration(self):
54
        return self.step_1_duration + self.step_2_duration + self.step_3_duration
55

  
56
    @property
52 57
    def success(self):
53 58
        return self._success
54 59

  
......
133 138
    values = []
134 139
    for d in deployments:
135 140
        if d.success and not d.has_retries:
136
            values.append(int(d.step_1_duration + d.step_2_duration + d.step_3_duration))
141
            value = d.deployment_duration
142
            if d.step_1_duration > 5 and d.step_2_duration > 10 and d.step_3_duration > 10:
143
                values.append(value)
144

  
145
            # values.append(value)
137 146
            # values.append(int(d.step_3_duration))
138 147
            # values.append(int(d.step_1_duration))
139 148

  
140 149
    title = 'Deployment on Cluster %s (%d)' % (cluster, year)
150
    # title = 'Deployment on Cluster %s' % (cluster)
141 151
    out_file = out_dir + ("/deployment_%s_%d.pdf" % (cluster, year))
152
    # out_file = out_dir + ("/deployment_%s.pdf" % (cluster))
142 153
    hist_graph(values, title, 'Deployment Time (seconds)', '', out_file)
143 154

  
144 155

  
......
146 157
    ar1 = np.array(values)
147 158
    fig, ax = plt.subplots()
148 159

  
149
    num_bins = 20
160
    num_bins = 50
150 161
    n, bins, patches = plt.hist(ar1, bins=num_bins, histtype='bar',
151 162
                                normed=True, facecolor='#708090', alpha=0.5, rwidth=0.8)
152 163
    plt.subplots_adjust(left=0.15)
153 164

  
154 165
    max = round(bins[len(bins) - 1])
155 166
    density = gaussian_kde(ar1)
156
    xs = np.linspace(0,max,300)
167
    xs = np.linspace(0, max, 300)
157 168
    density.covariance_factor = lambda : .25
158 169
    density._compute_covariance()
159
    plt.plot(xs,density(xs), 'r--')
170
    # plt.plot(xs, density(xs), 'r--')
160 171

  
161 172
    ax.set_xlabel(x_label)
162 173
    ax.set_ylabel(y_label)
......
165 176
    ax.get_xaxis().tick_bottom()
166 177
    ax.get_yaxis().tick_left()
167 178

  
179
    # # original distribution
180
    # pdf = rayleigh.pdf(xs, loc=120, scale=230)
181
    # plt.plot(xs, pdf, 'r-')
182
    #
183
    # param = rayleigh.fit(ar1)
184
    # pdf_fitted = rayleigh.pdf(xs, loc=param[0], scale=param[1])
185
    # plt.plot(xs, pdf_fitted, 'b')
186

  
187
    # original distribution
188
    # pdf = lognorm.pdf(xs, 0.4, loc=10, scale=370)
189
    # plt.plot(xs, pdf, 'r-')
190

  
191
    dist_names = ['lognorm', 'beta', 'betaprime', 'gamma', 'rayleigh']
192

  
193
    for dist_name in dist_names:
194
        dist = getattr(stats, dist_name)
195
        param = dist.fit(ar1)
196
        pdf_fitted = dist.pdf(xs, *param[:-2], loc=param[-2], scale=param[-1])
197
        plt.plot(xs, pdf_fitted, label=dist_name)
198
        plt.xlim(0, max)
199
    plt.legend(loc='upper right')
200

  
201
    # param = lognorm.fit(ar1)
202
    # pdf_fitted = lognorm.pdf(xs, param[0], loc=param[1], scale=param[2])
203
    # plt.plot(xs, pdf_fitted, 'b')
204

  
205
    # param = norm.fit(ar1)
206
    # pdf_fitted = norm.pdf(xs, loc=param[0], scale=param[1])
207
    # plt.plot(xs, pdf_fitted, 'b')
208

  
209
    #print param
210

  
168 211
    plt.show()
169 212
    # plt.savefig(out_file)
170 213

  
214

  
215

  
216

  
171 217
def plot_graphs():
172 218
    opts = parse_kdeploy_opt()
173 219
    deployments = parse_log(opts.input, opts.cluster)

Formats disponibles : Unified diff