Maintain some stats about our requests.

def update_stats(self, responses, no_responses):
        """
        Maintain some stats about our requests.

        """
        slowest_rtt = 0.0
        slowest_ip  = None
        fastest_rtt = 9999999.9
        fastest_ip  = None
        rtt_total   = 0.0

        for ip, rtt in responses.items():
            rtt_total += rtt
            if rtt > slowest_rtt:
                slowest_rtt = rtt
                slowest_ip  = ip
            elif rtt < fastest_rtt:
                fastest_rtt = rtt
                fastest_ip  = ip

        sorted_rtts = sorted(responses.values())
        l           = len(sorted_rtts)
        if l == 0:
            median_rtt = 0.0
        elif l % 2 == 1:
            # Odd number: Median is the middle element
            median_rtt = sorted_rtts[int(l / 2)]
        else:
            # Even number (average between two middle elements)
            median_rtt = (sorted_rtts[int(l / 2) - 1] +
                          sorted_rtts[int(l / 2)]) / 2.0

        now = datetime.datetime.now().isoformat()
        m = {
            "time" : now,
            "num_responses" : len(responses),
            "num_no_responses" : len(no_responses),
            "slowest" : {
                "ip"  : slowest_ip,
                "rtt" : slowest_rtt
            },
            "fastest" : {
                "ip"  : fastest_ip,
                "rtt" : fastest_rtt
            },
            "average_rtt" : rtt_total / len(responses),
            "median_rtt" : median_rtt
        }

        self.measurements.insert(0, m)
        self.measurements = self.measurements[:self.max_num_measurements]