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
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
def main(): window = gtk.Window() box = gtk.VBox(False) window.add(box) if True: data = [[ 7, 7, 7, 7, 7, 7, 7, 7, 12, 10, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 ], [4, 7, 10, 4, 7, 7, 7, 10, 12, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] graph = make_graph_pixmap(data, ['recv x10B/s', 'sent x10B/s', ' pixels/s'], 360, 165, "Bandwidth", True, False, None, rounding=100) image = gtk.Image() image.set_from_pixmap(graph, None) box.add(image) if True: data = [[ 6.761074066162109, 7.436990737915039, 5.215167999267578, 6.270885467529297, 5.424976348876953, 6.54292106628418, 2.619028091430664, 5.944013595581055, 5.134105682373047, 5.10096549987793, 5.944967269897461, 5.656957626342773, 8.015155792236328, 5.669116973876953, 4.487037658691406, 5.110979080200195, 5.182027816772461, 5.619049072265625, 4.729032516479492, 5.012035369873047 ], [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 2.0, 2.0, 2.0, 1.0, 1.0, 2.0, 3.0, 4.0, 2.0, 2.0, 3.0, 3.0 ]] graph = make_graph_pixmap(data, ['server', 'client'], 360, 165, "Latency (ms)", True, False, 10, rounding=10) image = gtk.Image() image.set_from_pixmap(graph, None) box.add(image) window.connect("destroy", gtk.main_quit) window.show_all() gtk.main()
def main(): window = gtk.Window() box = gtk.VBox(False) window.add(box) if True: data = [ [7, 7, 7, 7, 7, 7, 7, 7, 12, 10, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [4, 7, 10, 4, 7, 7, 7, 10, 12, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ] graph = make_graph_pixmap( data, ["recv x10B/s", "sent x10B/s", " pixels/s"], 360, 165, "Bandwidth", True, False, None, rounding=100 ) image = gtk.Image() image.set_from_pixmap(graph, None) box.add(image) if True: data = [ [ 6.761074066162109, 7.436990737915039, 5.215167999267578, 6.270885467529297, 5.424976348876953, 6.54292106628418, 2.619028091430664, 5.944013595581055, 5.134105682373047, 5.10096549987793, 5.944967269897461, 5.656957626342773, 8.015155792236328, 5.669116973876953, 4.487037658691406, 5.110979080200195, 5.182027816772461, 5.619049072265625, 4.729032516479492, 5.012035369873047, ], [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 2.0, 2.0, 2.0, 1.0, 1.0, 2.0, 3.0, 4.0, 2.0, 2.0, 3.0, 3.0], ] graph = make_graph_pixmap(data, ["server", "client"], 360, 165, "Latency (ms)", True, False, 10, rounding=10) image = gtk.Image() image.set_from_pixmap(graph, None) box.add(image) window.connect("destroy", gtk.main_quit) window.show_all() gtk.main()
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
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