Exemple #1
0
    def add_stats(self, info, suffix=""):
        #encoding stats:
        if len(self.encoding_stats)>0:
            estats = list(self.encoding_stats)
            encodings_used = [x[0] for x in estats]
            def add_compression_stats(enc_stats, suffix):
                comp_ratios_pct = []
                comp_times_ns = []
                total_pixels = 0
                total_time = 0.0
                for _, pixels, compressed_size, compression_time in enc_stats:
                    if compressed_size>0 and pixels>0:
                        osize = pixels*3
                        comp_ratios_pct.append((100.0*compressed_size/osize, pixels))
                        comp_times_ns.append((1000.0*1000*1000*compression_time/pixels, pixels))
                        total_pixels += pixels
                        total_time += compression_time
                add_weighted_list_stats(info, "compression_ratio_pct"+suffix, comp_ratios_pct)
                add_weighted_list_stats(info, "compression_pixels_per_ns"+suffix, comp_times_ns)
                info["pixels_encoded_per_second"+suffix] = int(total_pixels / total_time)
            add_compression_stats(estats, suffix=suffix)
            for encoding in encodings_used:
                enc_stats = [x for x in estats if x[0]==encoding]
                add_compression_stats(enc_stats, suffix="%s[%s]" % (suffix, encoding))

        latencies = [x*1000 for _, _, _, x in list(self.damage_in_latency)]
        add_list_stats(info, "damage_in_latency",  latencies)
        latencies = [x*1000 for _, _, _, x in list(self.damage_out_latency)]
        add_list_stats(info, "damage_out_latency",  latencies)
        #per encoding totals:
        for encoding, totals in self.encoding_totals.items():
            info["total_frames%s[%s]" % (suffix, encoding)] = totals[0] 
            info["total_pixels%s[%s]" % (suffix, encoding)] = totals[1] 
Exemple #2
0
    def add_stats(self, info, window_ids=[], suffix=""):
        """
            Adds most of the statistics available to the 'info' dict passed in.
            This is used by server.py to provide those statistics to clients
            via the 'xpra info' command.
        """
        info["client_type%s" % suffix] = self.client_type
        info["client_version%s" % suffix] = self.client_version or "unknown"
        info["client_uuid%s" % suffix] = self.uuid
        info["keyboard%s" % suffix] = self.keyboard_config.enabled
        try:
            info["client_connection%s" % suffix] = str(
                self.protocol._conn.target)
        except:
            pass
        info["client_encodings%s" % suffix] = ",".join(self.encodings)
        info["damage_data_queue_size%s.current" %
             suffix] = self.damage_data_queue.qsize()
        info["damage_packet_queue_size%s.current" % suffix] = len(
            self.damage_packet_queue)
        qpixels = [x[2] for x in list(self.damage_packet_queue)]
        add_list_stats(info, "damage_packet_queue_pixels%s" % suffix, qpixels)
        if len(qpixels) > 0:
            info["damage_packet_queue_pixels%s.current" % suffix] = qpixels[-1]
        self.ping()

        self.protocol.add_stats(info, suffix=suffix)
        self.statistics.add_stats(info, suffix=suffix)
        batch_delays = []
        if window_ids:
            total_pixels = 0
            total_time = 0.0
            for wid in window_ids:
                ws = self.window_sources.get(wid)
                if ws:
                    #per-window stats:
                    ws.add_stats(info, suffix=suffix)
                    #collect stats for global averages:
                    for _, pixels, _, encoding_time in list(
                            ws.statistics.encoding_stats):
                        total_pixels += pixels
                        total_time += encoding_time
                    if total_time > 0:
                        info["pixels_encoded_per_second%s" % suffix] = int(
                            total_pixels / total_time)
                    batch = ws.batch_config
                    for _, d in list(batch.last_delays):
                        batch_delays.append(d)
        if len(batch_delays) > 0:
            add_list_stats(info, "batch_delay%s" % suffix, batch_delays)
Exemple #3
0
    def add_stats(self, info, suffix=""):
        info["output_mmap_bytecount%s" % suffix] = self.mmap_bytes_sent
        if self.min_client_latency is not None:
            info["client_latency%s.absmin" % suffix] = int(
                self.min_client_latency * 1000)
        qsizes = [x for _, x in list(self.damage_data_qsizes)]
        add_list_stats(info, "damage_data_queue_size%s" % suffix, qsizes)
        qsizes = [x for _, x in list(self.damage_packet_qsizes)]
        add_list_stats(info, "damage_packet_queue_size%s" % suffix, qsizes)
        latencies = [x * 1000 for (_, _, _, x) in list(self.client_latency)]
        add_list_stats(info, "client_latency%s" % suffix, latencies)

        add_list_stats(info, "server_ping_latency%s" % suffix,
                       [1000.0 * x for _, x in list(self.server_ping_latency)])
        add_list_stats(info, "client_ping_latency%s" % suffix,
                       [1000.0 * x for _, x in list(self.client_ping_latency)])

        #client pixels per second:
        now = time.time()
        time_limit = now - 30  #ignore old records (30s)
        #pixels per second: decode time and overall
        total_pixels = 0  #total number of pixels processed
        total_time = 0  #total decoding time
        start_time = None  #when we start counting from (oldest record)
        region_sizes = []
        for _, event_time, pixels, decode_time in list(
                self.client_decode_time):
            #time filter and ignore failed decoding (decode_time==0)
            if event_time < time_limit or decode_time <= 0:
                continue
            if start_time is None or start_time > event_time:
                start_time = event_time
            total_pixels += pixels
            total_time += decode_time
            region_sizes.append(pixels)
        log("total_time=%s, total_pixels=%s", total_time, total_pixels)
        if total_time > 0:
            pixels_decoded_per_second = int(total_pixels * 1000 * 1000 /
                                            total_time)
            info["pixels_decoded_per_second%s" %
                 suffix] = pixels_decoded_per_second
        if start_time:
            elapsed = now - start_time
            pixels_per_second = int(total_pixels / elapsed)
            info["pixels_per_second%s" % suffix] = pixels_per_second
            info["regions_per_second%s" % suffix] = int(
                len(region_sizes) / elapsed)
            info["average_region_size%s" % suffix] = int(total_pixels /
                                                         len(region_sizes))
Exemple #4
0
    def add_stats(self, info, suffix=""):
        #encoding stats:
        if len(self.encoding_stats) > 0:
            estats = list(self.encoding_stats)
            encodings_used = [x[0] for x in estats]

            def add_compression_stats(enc_stats, suffix):
                comp_ratios_pct = []
                comp_times_ns = []
                total_pixels = 0
                total_time = 0.0
                for _, pixels, compressed_size, compression_time in enc_stats:
                    if compressed_size > 0 and pixels > 0:
                        osize = pixels * 3
                        comp_ratios_pct.append(
                            (100.0 * compressed_size / osize, pixels))
                        comp_times_ns.append(
                            (1000.0 * 1000 * 1000 * compression_time / pixels,
                             pixels))
                        total_pixels += pixels
                        total_time += compression_time
                add_weighted_list_stats(info, "compression_ratio_pct" + suffix,
                                        comp_ratios_pct)
                add_weighted_list_stats(info,
                                        "compression_pixels_per_ns" + suffix,
                                        comp_times_ns)
                info["pixels_encoded_per_second" + suffix] = int(total_pixels /
                                                                 total_time)

            add_compression_stats(estats, suffix=suffix)
            for encoding in encodings_used:
                enc_stats = [x for x in estats if x[0] == encoding]
                add_compression_stats(enc_stats,
                                      suffix="%s[%s]" % (suffix, encoding))

        latencies = [x * 1000 for _, _, _, x in list(self.damage_in_latency)]
        add_list_stats(info, "damage_in_latency", latencies)
        latencies = [x * 1000 for _, _, _, x in list(self.damage_out_latency)]
        add_list_stats(info, "damage_out_latency", latencies)
        #per encoding totals:
        for encoding, totals in self.encoding_totals.items():
            info["total_frames%s[%s]" % (suffix, encoding)] = totals[0]
            info["total_pixels%s[%s]" % (suffix, encoding)] = totals[1]
Exemple #5
0
    def add_stats(self, info, suffix=""):
        info["output_mmap_bytecount%s" % suffix] = self.mmap_bytes_sent
        if self.min_client_latency:
            info["client_latency%s.absmin" % suffix] = int(self.min_client_latency*1000)
        qsizes = [x for _,x in list(self.damage_data_qsizes)]
        add_list_stats(info, "damage_data_queue_size%s" % suffix,  qsizes)
        qsizes = [x for _,x in list(self.damage_packet_qsizes)]
        add_list_stats(info, "damage_packet_queue_size%s" % suffix,  qsizes)
        latencies = [x*1000 for (_, _, _, x) in list(self.client_latency)]
        add_list_stats(info, "client_latency%s" % suffix,  latencies)

        add_list_stats(info, "server_ping_latency%s" % suffix, self.server_ping_latency)
        add_list_stats(info, "client_ping_latency%s" % suffix, self.client_ping_latency)

        #client pixels per second:
        now = time.time()
        time_limit = now-30             #ignore old records (30s)
        #pixels per second: decode time and overall
        total_pixels = 0                #total number of pixels processed
        total_time = 0                  #total decoding time
        start_time = None               #when we start counting from (oldest record)
        region_sizes = []
        for _, event_time, pixels, decode_time in self.client_decode_time:
            #time filter and ignore failed decoding (decode_time==0)
            if event_time<time_limit or decode_time<=0:
                continue
            if start_time is None or start_time>event_time:
                start_time = event_time
            total_pixels += pixels
            total_time += decode_time
            region_sizes.append(pixels)
        log("total_time=%s, total_pixels=%s", total_time, total_pixels)
        if total_time>0:
            pixels_decoded_per_second = int(total_pixels *1000*1000 / total_time)
            info["pixels_decoded_per_second%s" % suffix] = pixels_decoded_per_second
        if start_time:
            elapsed = now-start_time
            pixels_per_second = int(total_pixels/elapsed)
            info["pixels_per_second%s" % suffix] = pixels_per_second
            info["regions_per_second%s" % suffix] = int(len(region_sizes)/elapsed)
            info["average_region_size%s" % suffix] = int(total_pixels/len(region_sizes))
Exemple #6
0
 def add_stats(self, info, suffix=""):
     """
         Add window specific stats
     """
     suffix += "[%s]" % self.wid
     info["encoding" + suffix] = self.encoding
     self.statistics.add_stats(info, suffix)
     #batch stats:
     if len(self.batch_config.last_delays) > 0:
         batch_delays = [x for _, x in self.batch_config.last_delays]
         add_list_stats(info, "batch_delay" + suffix, batch_delays)
     if self._video_encoder is not None:
         try:
             self._video_encoder_lock.acquire()
             quality_list = [x for _, x in self._video_encoder_quality]
             add_list_stats(info,
                            self._video_encoder.get_type() + "_quality" +
                            suffix,
                            quality_list,
                            show_percentile=False)
             speed_list = [x for _, x in self._video_encoder_speed]
             add_list_stats(info,
                            self._video_encoder.get_type() + "_speed" +
                            suffix,
                            speed_list,
                            show_percentile=False)
         finally:
             self._video_encoder_lock.release()
Exemple #7
0
    def add_stats(self, info, window_ids=[], suffix=""):
        """
            Adds most of the statistics available to the 'info' dict passed in.
            This is used by server.py to provide those statistics to clients
            via the 'xpra info' command.
        """
        info["client_encodings%s" % suffix] = ",".join(self.encodings)
        info["damage_data_queue_size%s.current" % suffix] = self.damage_data_queue.qsize()
        info["damage_packet_queue_size%s.current" % suffix] = len(self.damage_packet_queue)
        qpixels = [x[2] for x in list(self.damage_packet_queue)]
        add_list_stats(info, "damage_packet_queue_pixels%s" % suffix,  qpixels)
        if len(qpixels)>0:
            info["damage_packet_queue_pixels%s.current" % suffix] = qpixels[-1]
        self.ping()

        self.protocol.add_stats(info, suffix=suffix)
        self.statistics.add_stats(info, suffix=suffix)
        batch_delays = []
        if window_ids:
            total_pixels = 0
            total_time = 0.0
            for wid in window_ids:
                ws = self.window_sources.get(wid)
                if ws:
                    #per-window stats:
                    ws.add_stats(info, suffix=suffix)
                    #collect stats for global averages:
                    for _, pixels, _, encoding_time in ws.statistics.encoding_stats:
                        total_pixels += pixels
                        total_time += encoding_time
                    info["pixels_encoded_per_second%s" % suffix] = int(total_pixels / total_time)
                    batch = ws.batch_config
                    for _,d in list(batch.last_delays):
                        batch_delays.append(d)
        if len(batch_delays)>0:
            add_list_stats(info, "batch_delay%s" % suffix, batch_delays)
Exemple #8
0
 def add_stats(self, info, suffix=""):
     """
         Add window specific stats
     """
     suffix += "[%s]" % self.wid
     info["encoding"+suffix] = self.encoding
     self.statistics.add_stats(info, suffix)
     #batch stats:
     if len(self.batch_config.last_actual_delays)>0:
         batch_delays = [x for _,x in list(self.batch_config.last_delays)]
         add_list_stats(info, "batch_delay"+suffix, batch_delays)
     try:
         quality_list, speed_list = None, None
         self._video_encoder_lock.acquire()
         if self._video_encoder is not None:
             quality_list = [x for _, x in list(self._video_encoder_quality)]
             speed_list = [x for _, x in list(self._video_encoder_speed)]
     finally:
         self._video_encoder_lock.release()
     if quality_list and speed_list:
         add_list_stats(info, self._video_encoder.get_type()+"_quality"+suffix, quality_list, show_percentile=False)
         add_list_stats(info, self._video_encoder.get_type()+"_speed"+suffix, speed_list, show_percentile=False)