Skip to content

Commit ab6efc1

Browse files
committed
gtk_mesa_tests: Fix calculation in %
#4082 changed the time values from cycles to ns. This broke the calculation of % values and the CPU clock is not needed any more.
1 parent 78817f3 commit ab6efc1

1 file changed

Lines changed: 2 additions & 40 deletions

File tree

lib/python/gladevcp/builtin-panels/gtk_mesa_tests/gtk_mesa_tests.py

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,6 @@ def on_btn_calc_servo_released(self, gtkbutton):
337337

338338
combo_unit = self.builder.get_object("cbx_cpu_units_servo")
339339
unit = combo_unit.get_active_id()
340-
341-
spin_speed = self.builder.get_object("sbtn_cpu_speed_servo")
342-
cpu_speed = spin_speed.get_value()
343340

344341
label_result = self.builder.get_object("lbl_result_servo")
345342

@@ -356,24 +353,8 @@ def on_btn_calc_servo_released(self, gtkbutton):
356353
buffer.insert(buffer.get_end_iter(), "Servo Thread period must be greater than 0")
357354
return
358355

359-
if cpu_speed <= 0:
360-
if buffer.get_char_count() > 0:
361-
buffer.insert(buffer.get_end_iter(), "\n\n")
362-
buffer.insert(buffer.get_end_iter(), "CPU Speed must be greater than 0")
363-
return
364-
365-
# Unit conversion
366-
if unit == "MHz":
367-
cpu_speed_hz = cpu_speed * 1E6
368-
elif unit == "GHz":
369-
cpu_speed_hz = cpu_speed * 1E9
370-
371356
# Calculation
372-
cpu_clock_time = 0.000000001 * period
373-
clocks_per_period = cpu_speed_hz * cpu_clock_time
374-
375-
cpu_clocks_used = t_max / clocks_per_period
376-
result = cpu_clocks_used * 100
357+
result = t_max / period * 100
377358
label_result.set_text(f'{result:.0f}%')
378359

379360

@@ -474,9 +455,6 @@ def on_btn_nic_calculate_released(self, gtkbutton):
474455

475456
combo_unit = self.builder.get_object("cbx_cpu_units_nic")
476457
unit = combo_unit.get_active_id()
477-
478-
spin_speed = self.builder.get_object("sbtn_cpu_speed_nic")
479-
cpu_speed = spin_speed.get_value()
480458

481459
label_result = self.builder.get_object("lbl_result_nic")
482460

@@ -499,25 +477,9 @@ def on_btn_nic_calculate_released(self, gtkbutton):
499477
buffer.insert(buffer.get_end_iter(), "Servo Thread period must be greater than 0")
500478
return
501479

502-
if cpu_speed <= 0:
503-
if buffer.get_char_count() > 0:
504-
buffer.insert(buffer.get_end_iter(), "\n\n")
505-
buffer.insert(buffer.get_end_iter(), "CPU Speed must be greater than 0")
506-
return
507-
508-
# Unit conversion
509-
if unit == "MHz":
510-
cpu_speed_hz = cpu_speed * 1E6
511-
elif unit == "GHz":
512-
cpu_speed_hz = cpu_speed * 1E9
513-
514480
# Calculation
515481
rw_tmax = read_tmax + write_tmax
516-
cpu_clock_time = 0.000000001 * period
517-
clocks_per_period = cpu_speed_hz * cpu_clock_time
518-
519-
packet_time = rw_tmax / clocks_per_period
520-
result = packet_time * 100
482+
result = rw_tmax / period * 100
521483
label_result.set_text(f'{result:.0f}%')
522484

523485
def on_btn_packet_error_released(self, gtkbutton):

0 commit comments

Comments
 (0)