@@ -23,6 +23,9 @@ def __init__(self, app, server):
23
23
self .stop_event = threading .Event ()
24
24
self .app = app
25
25
self .server = server
26
+
27
+ self .start_time = 0
28
+ self .last_label_update = 0
26
29
27
30
def run (self ):
28
31
event_loop = asyncio .new_event_loop ()
@@ -61,26 +64,26 @@ def on_event(type):
61
64
view .ping = f"{ self .results .ping :.1f} ms"
62
65
view .jitter = f"{ self .results .jitter :.1f} ms"
63
66
elif type == "download_start" :
64
- timeout = GLib . timeout_add ( 1000 / 30 , lambda : self .update (view .download , self .results .total_dl , False ))
67
+ timeout = view . download . get_frame_clock (). connect ( "before-paint" , lambda * _ : self .update (view .download , self .results .total_dl , False ))
65
68
66
69
view .progress .remove_css_class ("up" )
67
70
view .progress .add_css_class ("dl" )
68
71
view .download .add_css_class ("active" )
69
72
70
73
self .start_time = time .time ()
71
74
elif type == "download_end" :
72
- GLib . source_remove (timeout )
75
+ view . download . get_frame_clock (). disconnect (timeout )
73
76
view .download .remove_css_class ("active" )
74
77
elif type == "upload_start" :
75
- timeout = GLib . timeout_add ( 1000 / 30 , lambda : self .update (view .upload , self .results .total_up , True ))
78
+ timeout = view . upload . get_frame_clock (). connect ( "before-paint" , lambda * _ : self .update (view .upload , self .results .total_up , True ))
76
79
77
80
view .progress .remove_css_class ("dl" )
78
81
view .progress .add_css_class ("up" )
79
82
view .upload .add_css_class ("active" )
80
83
81
84
self .start_time = time .time ()
82
85
elif type == "upload_end" :
83
- GLib . source_remove (timeout )
86
+ view . upload . get_frame_clock (). disconnect (timeout )
84
87
view .upload .remove_css_class ("active" )
85
88
86
89
GLib .idle_add (self .app .win .test_view .progress .set_visible , True )
@@ -99,7 +102,9 @@ def update(self, gauge, total, part_two):
99
102
100
103
if current_duration > 1 :
101
104
speedMb = round (value / 125_000 , 1 )
102
- gauge .value = str (speedMb ) + "Mbps"
105
+ if time .time () - self .last_label_update >= 0.075 :
106
+ gauge .value = str (speedMb ) + "Mbps"
107
+ self .last_label_update = time .time ()
103
108
gauge .fill = min (speedMb / self .app .settings .get_int ("gauge-scale" ), 1.0 )
104
109
105
110
view .progress .set_fraction (current_duration / DURATION * 0.5 + (0.5 if part_two else 0.0 ))
0 commit comments