Esempio n. 1
0
 def __init__(self, m, mode="chunk"):
     self.mode = mode
     self.m = m
     self.dotN = 0
     self.sum = 0
     self.minv = 1
     self.maxv = 0
     self.pkt_loss = PktLoss()
Esempio n. 2
0
class ErrorBarData(object):
    def __init__(self, m, mode="chunk"):
        self.mode = mode
        self.m = m
        self.dotN = 0
        self.sum = 0
        self.minv = 1
        self.maxv = 0
        self.pkt_loss = PktLoss()
        
    def add_dot_pair(self, dot1, dot2, mode=None):
        assert dot1.m == self.m
        #assert dot2.m == 1.0
        #print dot1.chunk_loss_rate, dot2.chunk_loss_rate
        if mode == None:
            mode = self.mode
            
        if mode == "chunk":
            temp = dot1.chunk_loss_rate/float(dot2.chunk_loss_rate)
        elif mode == "packet":
            temp = self.pkt_loss.estimate_accordiing_to_chunk_loss_rate(chunk_loss_rate=dot1.chunk_loss_rate, m=dot1.m)/float(dot2.chunk_loss_rate)
        elif mode == "ratio":
            temp = dot1.ratio/dot2.ratio     
        elif mode == "bitrate":
            temp = dot1.bitrate/dot2.bitrate
        #print "add temp=%s" %(temp)
        if temp > self.maxv:
            self.maxv = temp
        if temp < self.minv:
            self.minv = temp
            
        self.sum += temp
        self.dotN += 1
        
    def get_data(self):
        if self.dotN == 0:
            return 0, 0, 0
        
        return self.sum/float(self.dotN), self.maxv, self.minv