Exemplo n.º 1
0
 def results(self):
     results = Tree({'MEAN': self.mean_stretch/self.sess_count,
                     'MEAN_REQUEST': self.mean_req_stretch/self.sess_count,
                     'MEAN_CONTENT': self.mean_cont_stretch/self.sess_count})
     if self.cdf:
         results['CDF'] = cdf(self.stretch_data)
         results['CDF_REQUEST'] = cdf(self.req_stretch_data)
         results['CDF_CONTENT'] = cdf(self.cont_stretch_data)
     return results
Exemplo n.º 2
0
 def results(self):
     results = Tree({
         "MEAN":
         self.mean_stretch / self.sess_count,
         "MEAN_REQUEST":
         self.mean_req_stretch / self.sess_count,
         "MEAN_CONTENT":
         self.mean_cont_stretch / self.sess_count,
     })
     if self.cdf:
         results["CDF"] = cdf(self.stretch_data)
         results["CDF_REQUEST"] = cdf(self.req_stretch_data)
         results["CDF_CONTENT"] = cdf(self.cont_stretch_data)
     return results
Exemplo n.º 3
0
    def results(self):
        if self.cdf:
            results['CDF'] = cdf(self.latency_data)
        results = Tree(
            {'SATISFACTION': 1.0 * self.n_satisfied / self.sess_count})
        per_service_sats = {}
        for service in self.service_requests.keys():
            per_service_sats[service] = 1.0 * self.service_satisfied[
                service] / self.service_requests[service]
        results['PER_SERVICE_SATISFACTION'] = per_service_sats
        results['PER_SERVICE_REQUESTS'] = self.service_requests
        results['PER_SERVICE_SAT_REQUESTS'] = self.service_satisfied
        results['SAT_TIMES'] = self.satrate_times
        results['IDLE_TIMES'] = self.idle_times
        results['NODE_IDLE_TIMES'] = self.node_idle_times
        results['LATENCY'] = self.latency_times
        results['DEADLINE_METRIC'] = self.deadline_metric_times
        results['CLOUD_SAT_TIMES'] = self.cloud_sat_times
        results['INSTANTIATION_OVERHEAD'] = self.instantiations_times

        #print "Printing Sat. rate times:"
        #for key in sorted(self.satrate_times):
        #    print (repr(key) + " " + repr(self.satrate_times[key]))

        #print "Printing Idle times:"
        #for key in sorted(self.idle_times):
        #    print (repr(key) + " " + repr(self.idle_times[key]))
        #results['VMS_PER_SERVICE'] = self.vms_per_service

        return results
Exemplo n.º 4
0
 def results(self):
     results = Tree({
        'MEAN_RSN_ZERO_HOP':     np.mean(self.rsn_hit_ratio[0]),
        'MEAN_RSN_ONE_HOP':      np.mean(self.rsn_hit_ratio[1]),
        'MEAN_RSN_TWO_HOP':      np.mean(self.rsn_hit_ratio[2]),
        'MEAN_RSN_THREE_HOP':    np.mean(self.rsn_hit_ratio[3]),
               })
     results['MEAN_RSN_ALL'] = results['MEAN_RSN_ZERO_HOP'] + \
                               results['MEAN_RSN_ONE_HOP'] + \
                               results['MEAN_RSN_TWO_HOP'] + \
                               results['MEAN_RSN_THREE_HOP']  
     if self.cdf:
         results.update({
            'CDF_RSN_ZERO_HOP':      cdf(self.rsn_hit_ratio[0]),
            'CDF_RSN_ONE_HOP':       cdf(self.rsn_hit_ratio[1]),
            'CDF_RSN_TWO_HOP':       cdf(self.rsn_hit_ratio[2]),
            'CDF_RSN_THREE_HOP':     cdf(self.rsn_hit_ratio[3]),
                        })
     return results
Exemplo n.º 5
0
 def test_cdf_all_zeros(self):
     data = np.zeros(200)
     x, cdf = stats.cdf(data)
     exp_x = [0]
     exp_cdf = [1.0]
     self.assertEqual(len(x), len(exp_x))
     self.assertEqual(len(cdf), len(exp_cdf))
     for i in range(len(exp_x)):
         self.assertAlmostEqual(x[i], exp_x[i])
         self.assertAlmostEqual(cdf[i], exp_cdf[i])
Exemplo n.º 6
0
 def test_cdf_all_zeros(self):
     data = np.zeros(200)
     x, cdf = stats.cdf(data)
     exp_x = [0]
     exp_cdf = [1.0]
     assert len(x) == len(exp_x)
     assert len(cdf) == len(exp_cdf)
     for i in range(len(exp_x)):
         assert round(abs(x[i] - exp_x[i]), 7) == 0
         assert round(abs(cdf[i] - exp_cdf[i]), 7) == 0
Exemplo n.º 7
0
 def test_cdf_all_zeros(self):
     data = np.zeros(200)
     x, cdf = stats.cdf(data)
     exp_x = [0]
     exp_cdf = [1.0]
     self.assertEqual(len(x), len(exp_x))
     self.assertEqual(len(cdf), len(exp_cdf))
     for i in range(len(exp_x)):
         self.assertAlmostEqual(x[i], exp_x[i])
         self.assertAlmostEqual(cdf[i], exp_cdf[i])
Exemplo n.º 8
0
 def test_cdf_known_input(self):
     data = [-25, -25, 0.5, 1.1, 1.1, 1.1, 1.4, 1.4, 1.4, 1.4]
     # CDF(-25) = 0.2
     # CDF(0.5) = 0.3
     # CDF(1.1) = 0.6
     # CDF(1.5) = 1.0
     x, cdf = stats.cdf(data)
     exp_x = [-25, 0.5, 1.1, 1.4]
     exp_cdf = [0.2, 0.3, 0.6, 1.0]
     self.assertEqual(len(x), len(exp_x))
     self.assertEqual(len(cdf), len(exp_cdf))
     for i in range(len(exp_x)):
         self.assertAlmostEqual(x[i], exp_x[i])
         self.assertAlmostEqual(cdf[i], exp_cdf[i])
Exemplo n.º 9
0
 def test_cdf_known_input(self):
     data = [-25, -25, 0.5, 1.1, 1.1, 1.1, 1.4, 1.4, 1.4, 1.4]
     # CDF(-25) = 0.2
     # CDF(0.5) = 0.3
     # CDF(1.1) = 0.6
     # CDF(1.5) = 1.0
     x, cdf = stats.cdf(data)
     exp_x = [-25, 0.5, 1.1, 1.4]
     exp_cdf = [0.2, 0.3, 0.6, 1.0]
     assert len(x) == len(exp_x)
     assert len(cdf) == len(exp_cdf)
     for i in range(len(exp_x)):
         assert round(abs(x[i] - exp_x[i]), 7) == 0
         assert round(abs(cdf[i] - exp_cdf[i]), 7) == 0
Exemplo n.º 10
0
 def test_cdf_known_input(self):
     data = [-25, -25, 0.5, 1.1, 1.1, 1.1, 1.4, 1.4, 1.4, 1.4]
     # CDF(-25) = 0.2
     # CDF(0.5) = 0.3
     # CDF(1.1) = 0.6
     # CDF(1.5) = 1.0
     x, cdf = stats.cdf(data)
     exp_x = [-25, 0.5, 1.1, 1.4]
     exp_cdf = [0.2, 0.3, 0.6, 1.0]
     self.assertEqual(len(x), len(exp_x))
     self.assertEqual(len(cdf), len(exp_cdf))
     for i in range(len(exp_x)):
         self.assertAlmostEqual(x[i], exp_x[i])
         self.assertAlmostEqual(cdf[i], exp_cdf[i])
Exemplo n.º 11
0
    def results(self):
        # Idle times
        num_nodes = len(self.css.keys())
        node_idle_times = [0.0 for x in range(0, num_nodes)]
        node_vms = [0 for x in range(0, num_nodes)]

        for flow in self.flow_start.keys():
            duration = self.flow_end[flow] - self.flow_start[flow]
            self.latency += duration

        for node, cs in self.css.items():
            num_of_vms = cs.numOfVMs
            node_vms[node] = num_of_vms
            for indx in range(0, num_of_vms):
                node_idle_times[node] += cs.getIdleTime(indx, self.last_timestamp)
            node_idle_times[node] /= num_of_vms 

        # Idle times
        if self.cdf:
            results['CDF'] = cdf(self.latency_data)
        results = Tree({'LATENCY' : 1.0*self.latency/self.sess_count})
        per_service_sats = {}
        for service in self.service_requests.keys():
            per_service_sats[service] = 1.0*self.service_satisfied[service]/self.service_requests[service]
        results['PER_SERVICE_REQUESTS'] = self.service_requests
        results['IDLE_TIMES'] = node_idle_times 
        results['NUM_OF_VMS'] = node_vms
        
        #print "Printing Idle times:"
        #node = 0
        #for idle_time in node_idle_times:
        #    print (repr(node) + " " + repr(node_idle_times[node]))
        #    node += 1
        #print ("Flow starts:\n")
        #for flow in self.flow_start.keys():
        #    print (repr(flow) + " " + repr(self.flow_start[flow]))
        #print ("Flow ends:\n")
        #for flow in self.flow_end.keys():
        #    print (repr(flow) + " " + repr(self.flow_end[flow]))

        return results
Exemplo n.º 12
0
 def test_cdf_array_input(self):
     data = np.array(list(range(2000)))
     x, cdf = stats.cdf(data)
     self.assertEqual(len(x), 2000)
     self.assertAlmostEqual(cdf[-1], 1.0)
Exemplo n.º 13
0
 def results(self):
     results = Tree({'MEAN': self.latency/self.sess_count})
     if self.cdf:
         results['CDF'] = cdf(self.latency_data) 
     return results
Exemplo n.º 14
0
 def test_cdf_array_input(self):
     data = np.array(list(range(2000)))
     x, cdf = stats.cdf(data)
     self.assertEqual(len(x), 2000)
     self.assertAlmostEqual(cdf[-1], 1.0)
Exemplo n.º 15
0
 def test_cdf_deque_input(self):
     data = collections.deque(range(2000))
     x, cdf = stats.cdf(data)
     self.assertEqual(len(x), 2000)
     self.assertAlmostEqual(cdf[-1], 1.0)
Exemplo n.º 16
0
 def results(self):
     results = Tree({"MEAN": self.latency / self.sess_count})
     if self.cdf:
         results["CDF"] = cdf(self.latency_data)
     return results
Exemplo n.º 17
0
 def test_cdf_deque_input(self):
     data = collections.deque(range(2000))
     x, cdf = stats.cdf(data)
     self.assertEqual(len(x), 2000)
     self.assertAlmostEqual(cdf[-1], 1.0)
Exemplo n.º 18
0
 def test_cdf_array_input(self):
     data = np.array(list(range(2000)))
     x, cdf = stats.cdf(data)
     assert len(x) == 2000
     assert round(abs(cdf[-1] - 1.0), 7) == 0
Exemplo n.º 19
0
 def test_cdf_deque_input(self):
     data = collections.deque(range(2000))
     x, cdf = stats.cdf(data)
     assert len(x) == 2000
     assert round(abs(cdf[-1] - 1.0), 7) == 0