update boot time script

This commit is contained in:
Adeeb Shihadeh
2023-02-26 15:24:19 -08:00
parent 1e0f240f38
commit 58b63d8a26
+25 -2
View File
@@ -5,20 +5,40 @@ from tabulate import tabulate
# serial with timestamps:
# grabserial -d /dev/serial/by-id/usb-FTDI_FT230X* -t
# systemd-analyze critical-chain weston-ready.service
# systemd-analyze critical-chain weston.service
# systemd-analyze critical-chain comma.service
# boot chart:
# systemd-analyze plot > /tmp/bootup.svg
def get_journal_time(x):
out = subprocess.check_output("journalctl -x -o short-monotonic", shell=True, encoding='utf8')
jlines = out.strip().splitlines()
for l in jlines:
if x in l:
t = l.split('[')[1].split(']')[0]
return float(t)
return None
if __name__ == "__main__":
ts = {
"PON": 1.5, # estimate from powering on to XBL
# these are dumped over serial, use the ones from the XBL
"XBL": 2.4,
"ABL": 3.7, # 3s of this is waiting for fastboot + factory reset tapping
}
def tot_since_kern():
return sum(ts.values()) - (ts['PON'] + ts['XBL'] + ts['ABL'])
out = subprocess.check_output("systemd-analyze", shell=True, encoding='utf8')
l = out.splitlines()[0].split(' ')
ts['kernel'] = float(l[3][:-1])
ts['graphical.target'] = float(l[6][:-1])
#ts['systemd'] = float(l[6][:-1])
# includes /sbin/init -> weston being ready to display stuff
ts['weston'] = get_journal_time("Finished weston-ready.service") - tot_since_kern()
ts['comma'] = get_journal_time("Started Comma tmux") - tot_since_kern()
# print
tot = 0
@@ -32,4 +52,7 @@ if __name__ == "__main__":
round(tot, 2),
str(round(t/total * 100)) + "%",
])
# TODO: add openpilot time-to-onroad
tab.append(['onroad', '?', '?', '-'])
print(tabulate(tab))