mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-10-01 03:43:46 +08:00
Ban time v2 (#35744)
* ban it! * some legitimate blunders * even more! * this is from commaai/one * here too * this too * ignore rest * one liner * Revert "one liner" This reverts commit d96a1624032aaad829a005b523e579d953cfe690.
This commit is contained in:
@@ -47,15 +47,15 @@ if __name__ == "__main__":
|
||||
|
||||
num_pandas = len(messaging.recv_one_retry(pandaStates_sock).pandaStates)
|
||||
|
||||
t = time.time()
|
||||
t = time.monotonic()
|
||||
print("Getting vin...")
|
||||
set_obd_multiplexing(True)
|
||||
vin_rx_addr, vin_rx_bus, vin = get_vin(*can_callbacks, (0, 1))
|
||||
print(f'RX: {hex(vin_rx_addr)}, BUS: {vin_rx_bus}, VIN: {vin}')
|
||||
print(f"Getting VIN took {time.time() - t:.3f} s")
|
||||
print(f"Getting VIN took {time.monotonic() - t:.3f} s")
|
||||
print()
|
||||
|
||||
t = time.time()
|
||||
t = time.monotonic()
|
||||
fw_vers = get_fw_versions(*can_callbacks, set_obd_multiplexing, query_brand=args.brand, extra=extra, num_pandas=num_pandas, progress=True)
|
||||
_, candidates = match_fw_to_car(fw_vers, vin)
|
||||
|
||||
@@ -71,4 +71,4 @@ if __name__ == "__main__":
|
||||
|
||||
print()
|
||||
print("Possible matches:", candidates)
|
||||
print(f"Getting fw took {time.time() - t:.3f} s")
|
||||
print(f"Getting fw took {time.monotonic() - t:.3f} s")
|
||||
|
||||
@@ -37,8 +37,6 @@ monitored_proc_names = [
|
||||
|
||||
cpu_time_names = ['user', 'system', 'children_user', 'children_system']
|
||||
|
||||
timer = getattr(time, 'monotonic', time.time)
|
||||
|
||||
|
||||
def get_arg_parser():
|
||||
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
@@ -72,7 +70,7 @@ if __name__ == "__main__":
|
||||
print('Add monitored proc:', k)
|
||||
stats[k] = {'cpu_samples': defaultdict(list), 'min': defaultdict(lambda: None), 'max': defaultdict(lambda: None),
|
||||
'avg': defaultdict(float), 'last_cpu_times': None, 'last_sys_time': None}
|
||||
stats[k]['last_sys_time'] = timer()
|
||||
stats[k]['last_sys_time'] = time.monotonic()
|
||||
stats[k]['last_cpu_times'] = p.cpu_times()
|
||||
monitored_procs.append(p)
|
||||
i = 0
|
||||
@@ -80,7 +78,7 @@ if __name__ == "__main__":
|
||||
while True:
|
||||
for p in monitored_procs:
|
||||
k = ' '.join(p.cmdline())
|
||||
cur_sys_time = timer()
|
||||
cur_sys_time = time.monotonic()
|
||||
cur_cpu_times = p.cpu_times()
|
||||
cpu_times = np.subtract(cur_cpu_times, stats[k]['last_cpu_times']) / (cur_sys_time - stats[k]['last_sys_time'])
|
||||
stats[k]['last_sys_time'] = cur_sys_time
|
||||
|
||||
Reference in New Issue
Block a user