예제 #1
0
    def populate_graphs(self, *args):
        box = self.tab_box
        _, h = box.size_request()
        _, bh = self.tab_button_box.size_request()
        if h <= 0:
            return True
        start_x_offset = min(1.0, (time.time() - self.last_populate_time) * 0.95)
        rect = box.get_allocation()
        h = max(200, h - bh - 20, rect.height - bh - 20)
        w = max(360, rect.width - 20)
        # bandwidth graph:
        if self.net_in_data and self.net_out_data:

            def unit(scale):
                if scale == 1:
                    return ""
                else:
                    unit, value = to_std_unit(scale)
                    if value == 1:
                        return str(unit)
                    return "x%s%s" % (int(value), unit)

            labels = ["recv %sB/s" % unit(self.net_in_scale), "sent %sB/s" % unit(self.net_out_scale)]
            datasets = [self.net_in_data, self.net_out_data]
            if SHOW_PIXEL_STATS and self.client.windows_enabled:
                pixel_scale, in_pixels = values_to_scaled_values(
                    list(self.pixel_in_data)[3 : N_SAMPLES + 4], min_scaled_value=100
                )
                datasets.append(in_pixels)
                labels.append("%s pixels/s" % unit(pixel_scale))
            pixmap = make_graph_pixmap(
                datasets,
                labels=labels,
                width=w,
                height=h / 2,
                title="Bandwidth",
                min_y_scale=10,
                rounding=10,
                start_x_offset=start_x_offset,
            )
            self.bandwidth_graph.set_size_request(*pixmap.get_size())
            self.bandwidth_graph.set_from_pixmap(pixmap, None)
        # latency graph:
        for l in (self.server_latency, self.client_latency):
            if len(l) < 20:
                for _ in range(20 - len(l)):
                    l.insert(0, None)
        pixmap = make_graph_pixmap(
            [self.server_latency, self.client_latency],
            labels=["server", "client"],
            width=w,
            height=h / 2,
            title="Latency (ms)",
            min_y_scale=10,
            rounding=25,
            start_x_offset=start_x_offset,
        )
        self.latency_graph.set_size_request(*pixmap.get_size())
        self.latency_graph.set_from_pixmap(pixmap, None)
        return True
예제 #2
0
    def populate_graphs(self, *args):
        box = self.tab_box
        _, h = box.size_request()
        _, bh = self.tab_button_box.size_request()
        if h <= 0:
            return True
        start_x_offset = min(1.0,
                             (time.time() - self.last_populate_time) * 0.95)
        rect = box.get_allocation()
        h = max(200, h - bh - 20, rect.height - bh - 20)
        w = max(360, rect.width - 20)
        #bandwidth graph:
        if self.net_in_data and self.net_out_data:

            def unit(scale):
                if scale == 1:
                    return ""
                else:
                    unit, value = to_std_unit(scale)
                    if value == 1:
                        return str(unit)
                    return "x%s%s" % (int(value), unit)

            labels = [
                "recv %sB/s" % unit(self.net_in_scale),
                "sent %sB/s" % unit(self.net_out_scale)
            ]
            datasets = [self.net_in_data, self.net_out_data]
            if SHOW_PIXEL_STATS and self.client.windows_enabled:
                pixel_scale, in_pixels = values_to_scaled_values(
                    list(self.pixel_in_data)[3:N_SAMPLES + 4],
                    min_scaled_value=100)
                datasets.append(in_pixels)
                labels.append("%s pixels/s" % unit(pixel_scale))
            pixmap = make_graph_pixmap(datasets,
                                       labels=labels,
                                       width=w,
                                       height=h / 2,
                                       title="Bandwidth",
                                       min_y_scale=10,
                                       rounding=10,
                                       start_x_offset=start_x_offset)
            self.bandwidth_graph.set_size_request(*pixmap.get_size())
            self.bandwidth_graph.set_from_pixmap(pixmap, None)
        #latency graph:
        for l in (self.server_latency, self.client_latency):
            if len(l) < 20:
                for _ in range(20 - len(l)):
                    l.insert(0, None)
        pixmap = make_graph_pixmap([self.server_latency, self.client_latency],
                                   labels=["server", "client"],
                                   width=w,
                                   height=h / 2,
                                   title="Latency (ms)",
                                   min_y_scale=10,
                                   rounding=25,
                                   start_x_offset=start_x_offset)
        self.latency_graph.set_size_request(*pixmap.get_size())
        self.latency_graph.set_from_pixmap(pixmap, None)
        return True
예제 #3
0
    def populate_graphs(self, *args):
        if self.client.server_info_request:
            self.client.send_info_request()
        box = self.tab_box
        _, h = get_preferred_size(box)
        _, bh = get_preferred_size(self.tab_button_box)
        if h<=0:
            return True
        start_x_offset = min(1.0, (time.time()-self.last_populate_time)*0.95)
        rect = box.get_allocation()
        h = max(200, h-bh-20, rect.height-bh-20)
        w = max(360, rect.width-20)
        #bandwidth graph:
        labels, datasets = [], []
        if self.net_in_bytecount and self.net_out_bytecount:
            def unit(scale):
                if scale==1:
                    return ""
                else:
                    unit, value = to_std_unit(scale)
                    if value==1:
                        return str(unit)
                    return "x%s%s" % (int(value), unit)
            net_in_scale, net_in_data = values_to_diff_scaled_values(list(self.net_in_bytecount)[1:N_SAMPLES+3], scale_unit=1000, min_scaled_value=50)
            net_out_scale, net_out_data = values_to_diff_scaled_values(list(self.net_out_bytecount)[1:N_SAMPLES+3], scale_unit=1000, min_scaled_value=50)
            labels += ["recv %sB/s" % unit(net_in_scale), "sent %sB/s" % unit(net_out_scale)]
            datasets += [net_in_data, net_out_data]
        if SHOW_PIXEL_STATS and self.client.windows_enabled:
            pixel_scale, in_pixels = values_to_scaled_values(list(self.pixel_in_data)[3:N_SAMPLES+4], min_scaled_value=100)
            datasets.append(in_pixels)
            labels.append("%s pixels/s" % unit(pixel_scale))
        if SHOW_SOUND_STATS and self.sound_in_bytecount:
            sound_in_scale, sound_in_data =  values_to_diff_scaled_values(list(self.sound_in_bytecount)[1:N_SAMPLES+3], scale_unit=1000, min_scaled_value=50)
            datasets.append(sound_in_data)
            labels.append("Speaker %sB/s" % unit(sound_in_scale))
        if SHOW_SOUND_STATS and self.sound_out_bytecount:
            sound_out_scale, sound_out_data =  values_to_diff_scaled_values(list(self.sound_out_bytecount)[1:N_SAMPLES+3], scale_unit=1000, min_scaled_value=50)
            datasets.append(sound_out_data)
            labels.append("Mic %sB/s" % unit(sound_out_scale))

        if labels and datasets:
            pixmap = make_graph_pixmap(datasets, labels=labels,
                                       width=w, height=h/2,
                                       title="Bandwidth", min_y_scale=10, rounding=10,
                                       start_x_offset=start_x_offset)
            self.bandwidth_graph.set_size_request(*pixmap.get_size())
            self.bandwidth_graph.set_from_pixmap(pixmap, None)
        if self.client.server_info_request:
            pass
        #latency graph:
        latency_graph_items = (
                                (self.avg_ping_latency, "network"),
                                (self.avg_batch_delay, "batch delay"),
                                (self.avg_damage_out_latency, "encode&send"),
                                (self.avg_decoding_latency, "decoding"),
                                (self.avg_total, "frame total"),
                                )
        latency_graph_values = []
        labels = []
        for l, name in latency_graph_items:
            if len(l)==0:
                continue
            l = list(l)
            if len(l)<20:
                for _ in range(20-len(l)):
                    l.insert(0, None)
            latency_graph_values.append(l)
            labels.append(name)
        pixmap = make_graph_pixmap(latency_graph_values, labels=labels,
                                    width=w, height=h/2,
                                    title="Latency (ms)", min_y_scale=10, rounding=25,
                                    start_x_offset=start_x_offset)
        self.latency_graph.set_size_request(*pixmap.get_size())
        self.latency_graph.set_from_pixmap(pixmap, None)
        return True
예제 #4
0
 def populate_graphs(self, *args):
     if self.client.server_info_request:
         self.client.send_info_request()
     box = self.tab_box
     _, h = get_preferred_size(box)
     _, bh = get_preferred_size(self.tab_button_box)
     if h<=0:
         return True
     start_x_offset = min(1.0, (time.time()-self.last_populate_time)*0.95)
     rect = box.get_allocation()
     h = max(200, h-bh-20, rect.height-bh-20)
     w = max(360, rect.width-20)
     #bandwidth graph:
     if self.net_in_data and self.net_out_data:
         def unit(scale):
             if scale==1:
                 return ""
             else:
                 unit, value = to_std_unit(scale)
                 if value==1:
                     return str(unit)
                 return "x%s%s" % (int(value), unit)
         labels = ["recv %sB/s" % unit(self.net_in_scale), "sent %sB/s" % unit(self.net_out_scale)]
         datasets = [self.net_in_data, self.net_out_data]
         if SHOW_PIXEL_STATS and self.client.windows_enabled:
             pixel_scale, in_pixels = values_to_scaled_values(list(self.pixel_in_data)[3:N_SAMPLES+4], min_scaled_value=100)
             datasets.append(in_pixels)
             labels.append("%s pixels/s" % unit(pixel_scale))
         pixmap = make_graph_pixmap(datasets, labels=labels,
                                    width=w, height=h/2,
                                    title="Bandwidth", min_y_scale=10, rounding=10,
                                    start_x_offset=start_x_offset)
         self.bandwidth_graph.set_size_request(*pixmap.get_size())
         self.bandwidth_graph.set_from_pixmap(pixmap, None)
     if self.client.server_info_request:
         pass
     #latency graph:
     latency_graph_items = (
                             (self.avg_ping_latency, "network"),
                             (self.avg_batch_delay, "batch delay"),
                             (self.avg_damage_out_latency, "encode&send"),
                             (self.avg_decoding_latency, "decoding"),
                             (self.avg_total, "frame total"),
                             )
     latency_graph_values = []
     labels = []
     for l, name in latency_graph_items:
         if len(l)==0:
             continue
         l = list(l)
         if len(l)<20:
             for _ in range(20-len(l)):
                 l.insert(0, None)
         latency_graph_values.append(l)
         labels.append(name)
     pixmap = make_graph_pixmap(latency_graph_values, labels=labels,
                                 width=w, height=h/2,
                                 title="Latency (ms)", min_y_scale=10, rounding=25,
                                 start_x_offset=start_x_offset)
     self.latency_graph.set_size_request(*pixmap.get_size())
     self.latency_graph.set_from_pixmap(pixmap, None)
     return True