From 3331edf265f694aac510114edf8a70784b39ad68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Resul=20=C3=96v=C3=BCr?= <92828257+ovurrsl@users.noreply.github.com> Date: Thu, 22 Oct 2026 17:40:48 +0300 Subject: [PATCH] perf: session log step times carry milliseconds (#993) The == STEP lines in session.log now read HH:MM:SS.mmm, so the setup steps before Steam starts can be timed; with whole seconds most of them showed the same time. Co-authored-by: ovurrsl Co-authored-by: xXJsonDeruloXx --- .../overlay/usr/local/bin/droiddeck-session | 2 +- tools/tests/test_session_step_time.py | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tools/tests/test_session_step_time.py diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session index 39ee3c8a6..236ff8598 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session @@ -3,7 +3,7 @@ set -u export HOME=${HOME:-/root} mode=${1:-desktop} shift || true -step() { echo "== STEP $(date -u +%H:%M:%S) $*"; } +step() { echo "== STEP $(date -u +%H:%M:%S.%3N) $*"; } steam_setup_failed() { echo "== steam: the Steam client could not be set up (status $1)" [ -z "${BL_STEAM_EXIT_FILE:-}" ] || printf '%s\n' "$1" > "$BL_STEAM_EXIT_FILE" diff --git a/tools/tests/test_session_step_time.py b/tools/tests/test_session_step_time.py new file mode 100644 index 000000000..2622e34cc --- /dev/null +++ b/tools/tests/test_session_step_time.py @@ -0,0 +1,27 @@ +import re +import subprocess +import unittest +from pathlib import Path + +SESSION = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-session" + + +def step_function(): + match = re.search(r"^step\(\) \{.*\}$", SESSION.read_text(), re.M) + return match.group(0) + + +class SessionStepTimeTest(unittest.TestCase): + def test_a_step_line_carries_milliseconds_before_its_text(self): + out = subprocess.run(["bash", "-c", step_function() + "\nstep starting the Steam client"], + capture_output=True, text=True, timeout=30).stdout.strip() + self.assertRegex(out, r"^== STEP \d{2}:\d{2}:\d{2}\.\d{3} starting the Steam client$") + + def test_the_text_after_the_first_space_is_the_step_name(self): + out = subprocess.run(["bash", "-c", step_function() + "\nstep checking the Steam client"], + capture_output=True, text=True, timeout=30).stdout.strip() + self.assertEqual("checking the Steam client", out.removeprefix("== STEP ").split(" ", 1)[1]) + + +if __name__ == "__main__": + unittest.main()