def report(self):
        """Return a dictionary of different status codes and the percentage of time
        spent in each throughout the last summation_period seconds.
        Truncate the aggregated history appropriately."""
        timestamp = time.time()
        cutoff = timestamp - self.period
        truncate = 0
        summary = {}
        for event in self.status_history[:-1]:
            if event["end"] < cutoff:
                truncate = truncate + 1
                continue
            summary[event["status"]] = (
                summary.get(event["status"], 0)
                + event["end"]
                - max(cutoff, event["start"])
            )
        summary[self.status_history[-1]["status"]] = (
            summary.get(self.status_history[-1]["status"], 0)
            + timestamp
            - max(cutoff, self.status_history[-1]["start"])
        )
        if truncate:
            self.status_history = self.status_history[truncate:]
        total_duration = sum(summary.values())
        summary = {s: round(d / total_duration, 4) for s, d in summary.items()}
        return summary
def report ( self ) : timestamp = time . time ( ) cutoff = timestamp - self . period truncate = 0 summary = { } for event in self . status_history [ : - 1 ] : if event [ "end" ] < cutoff : truncate = truncate + 1 continue summary [ event [ "status" ] ] = ( summary . get ( event [ "status" ] , 0 ) + event [ "end" ] - max ( cutoff , event [ "start" ] ) ) summary [ self . status_history [ - 1 ] [ "status" ] ] = ( summary . get ( self . status_history [ - 1 ] [ "status" ] , 0 ) + timestamp - max ( cutoff , self . status_history [ - 1 ] [ "start" ] ) ) if truncate : self . status_history = self . status_history [ truncate : ] total_duration = sum ( summary . values ( ) ) summary = { s : round ( d / total_duration , 4 ) for s , d in summary . items ( ) } return summary
Return a dictionary of different status codes and the percentage of time
        spent in each throughout the last summation_period seconds.
        Truncate the aggregated history appropriately.