summaryrefslogtreecommitdiff
path: root/source/util
diff options
context:
space:
mode:
authorcirakg <cirakg@cirakg.xyz>2026-10-18 21:10:37 +0200
committercirakg <cirakg@cirakg.xyz>2026-10-18 21:10:37 +0200
commit773df56883b9961b607a1994920f5ef5299423b8 (patch)
treee813e8f975e3cfa7a992222e5bf63ef615469916 /source/util
parent2292bf700d28ade39cf2d64b45509e6db21034bc (diff)
feat(app): add minimal watch app with smoke test and per-size icons
The M0 placeholder app: AppBase entry point, home screen with name and version, debug-only diagnostics (start-up time, memory) and a unit test that runs in the headless simulator. Builds with strict type checking and zero warnings for all 72 products; icons.jungle gives every product a launcher icon of its exact size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'source/util')
-rw-r--r--source/util/Diag.mc50
1 files changed, 50 insertions, 0 deletions
diff --git a/source/util/Diag.mc b/source/util/Diag.mc
new file mode 100644
index 0000000..aea2a70
--- /dev/null
+++ b/source/util/Diag.mc
@@ -0,0 +1,50 @@
+// Author: cirakg & claude ai
+// Summary: Debug-only diagnostics (start-up time, memory) for `make perf` and `make memtest`.
+//
+// Debug builds print one machine-readable line per event to the simulator
+// console: "DIAG", the event name, then key=value pairs, for example
+// DIAG first_frame startup_ms=1 mem_used=6984 mem_total=781888
+// tools/check_budgets.py reads these lines and compares them with
+// tools/budgets.json. Plain key=value pairs are used instead of JSON because
+// the simulator console escapes quotes. Release builds compile the empty
+// (:release) versions instead, so a real watch running a release build never
+// logs anything.
+//
+// Security rule: only timings and memory counters ever go through here, never
+// secrets, codes or entry names. This is the only file allowed to call
+// System.println outside tests (enforced by tools/lint_project.py).
+
+import Toybox.Lang;
+import Toybox.System;
+
+module Diag {
+
+ // System.getTimer() value when the app object was created.
+ (:debug)
+ var startMs as Number = 0;
+
+ // Start the start-up timer. Called from OtpWalletApp.initialize().
+ (:debug)
+ function markStart() as Void {
+ startMs = System.getTimer();
+ }
+
+ (:release)
+ function markStart() as Void {
+ }
+
+ // Report start-up time and memory use after the first complete frame.
+ // startup_ms covers app object creation to the end of the first draw. The
+ // time the system needs to load the program before that is invisible to
+ // the app; app-diag.sh measures it from outside (README section 18).
+ (:debug)
+ function firstFrame() as Void {
+ var stats = System.getSystemStats();
+ System.println("DIAG first_frame startup_ms=" + (System.getTimer() - startMs)
+ + " mem_used=" + stats.usedMemory + " mem_total=" + stats.totalMemory);
+ }
+
+ (:release)
+ function firstFrame() as Void {
+ }
+}