mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-23 17:23:44 +08:00
@@ -23,11 +23,10 @@ class TestPackerMethods(unittest.TestCase):
|
||||
pump_on = (random.randint(0, 2) % 2 == 0)
|
||||
pcm_override = (random.randint(0, 2) % 2 == 0)
|
||||
pcm_cancel_cmd = (random.randint(0, 2) % 2 == 0)
|
||||
chime = random.randint(0, 65536)
|
||||
fcw = random.randint(0, 65536)
|
||||
idx = random.randint(0, 65536)
|
||||
m_old = hondacan.create_brake_command(self.honda_cp_old, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, chime, fcw, idx, car_fingerprint, is_panda_black)
|
||||
m = hondacan.create_brake_command(self.honda_cp, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, chime, fcw, idx, car_fingerprint, is_panda_black)
|
||||
m_old = hondacan.create_brake_command(self.honda_cp_old, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, fcw, idx, car_fingerprint, is_panda_black)
|
||||
m = hondacan.create_brake_command(self.honda_cp, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, fcw, idx, car_fingerprint, is_panda_black)
|
||||
self.assertEqual(m_old, m)
|
||||
|
||||
apply_steer = (random.randint(0, 2) % 2 == 0)
|
||||
@@ -39,8 +38,7 @@ class TestPackerMethods(unittest.TestCase):
|
||||
|
||||
pcm_speed = random.randint(0, 65536)
|
||||
hud = HUDData(random.randint(0, 65536), random.randint(0, 65536), 1, random.randint(0, 65536),
|
||||
0xc1, random.randint(0, 65536), random.randint(0, 65536), random.randint(0, 65536),
|
||||
random.randint(0, 65536), random.randint(0, 65536), random.randint(0, 65536))
|
||||
0xc1, random.randint(0, 65536), random.randint(0, 65536), random.randint(0, 65536), random.randint(0, 65536))
|
||||
idx = random.randint(0, 65536)
|
||||
is_metric = (random.randint(0, 2) % 2 == 0)
|
||||
m_old = hondacan.create_ui_commands(self.honda_cp_old, pcm_speed, hud, car_fingerprint, is_metric, idx, is_panda_black)
|
||||
|
||||
@@ -47,36 +47,32 @@ class TestPackerMethods(unittest.TestCase):
|
||||
self.assertEqual(m_old, m)
|
||||
|
||||
steer = (random.randint(0, 2) % 2 == 0)
|
||||
sound1 = random.randint(1, 65536)
|
||||
sound2 = random.randint(1, 65536)
|
||||
left_line = (random.randint(0, 2) % 2 == 0)
|
||||
right_line = (random.randint(0, 2) % 2 == 0)
|
||||
left_lane_depart = (random.randint(0, 2) % 2 == 0)
|
||||
right_lane_depart = (random.randint(0, 2) % 2 == 0)
|
||||
m_old = create_ui_command(self.cp_old, steer, sound1, sound2, left_line, right_line, left_lane_depart, right_lane_depart)
|
||||
m = create_ui_command(self.cp, steer, sound1, sound2, left_line, right_line, left_lane_depart, right_lane_depart)
|
||||
m_old = create_ui_command(self.cp_old, steer, left_line, right_line, left_lane_depart, right_lane_depart)
|
||||
m = create_ui_command(self.cp, steer, left_line, right_line, left_lane_depart, right_lane_depart)
|
||||
self.assertEqual(m_old, m)
|
||||
|
||||
def test_performance(self):
|
||||
n1 = sec_since_boot()
|
||||
recursions = 100000
|
||||
steer = (random.randint(0, 2) % 2 == 0)
|
||||
sound1 = random.randint(1, 65536)
|
||||
sound2 = random.randint(1, 65536)
|
||||
left_line = (random.randint(0, 2) % 2 == 0)
|
||||
right_line = (random.randint(0, 2) % 2 == 0)
|
||||
left_lane_depart = (random.randint(0, 2) % 2 == 0)
|
||||
right_lane_depart = (random.randint(0, 2) % 2 == 0)
|
||||
|
||||
for _ in xrange(recursions):
|
||||
create_ui_command(self.cp_old, steer, sound1, sound2, left_line, right_line, left_lane_depart, right_lane_depart)
|
||||
create_ui_command(self.cp_old, steer, left_line, right_line, left_lane_depart, right_lane_depart)
|
||||
n2 = sec_since_boot()
|
||||
elapsed_old = n2 - n1
|
||||
|
||||
# print('Old API, elapsed time: {} secs'.format(elapsed_old))
|
||||
n1 = sec_since_boot()
|
||||
for _ in xrange(recursions):
|
||||
create_ui_command(self.cp, steer, sound1, sound2, left_line, right_line, left_lane_depart, right_lane_depart)
|
||||
create_ui_command(self.cp, steer, left_line, right_line, left_lane_depart, right_lane_depart)
|
||||
n2 = sec_since_boot()
|
||||
elapsed_new = n2 - n1
|
||||
# print('New API, elapsed time: {} secs'.format(elapsed_new))
|
||||
|
||||
Reference in New Issue
Block a user