interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / aienux / allen / look-stat.om

215 lines · 5284 bytes Raw Blame History
1note SPDX-License-Identifier: MIT
2note Allen's look, the stopwatch: what a second of frames costs on the machine that runs the show.
3note look-show.om stamps three clocks a frame (before the decision, after compose and conversion,
4note after the blit); once a second the sums become one line
5note STAT net=<network ready> e=<last firmware error> h=<SNP handles> l=<locate status>
6note c=<efi 8 scans> p=<probe step per handle, hex> m=<adapter MAC, hex> s=<second>
7note t=<ms into the show> f=<frames> cc=<compose+convert ms> bl=<blit ms>
8note r=<rectangles> px=<pixels composed> full=<full redraws> max=<slowest frame ms>
9note lens=<w>x<h> rip=<ripple radius> kb=<KiB blitted>
10note The network fields come first so the 159-byte answer view never cuts them off.
11note sent as one datagram to the courier's port (the relay drops anything that is not courier
12note wire; tcpdump on the Spark reads it) and kept as Allen's answer to the typed line `stats`.
13note Stw: 0 second start ms, 1 frames, 2 compose+convert ms, 3 blit ms, 4 rectangles, 5 pixels,
14note 6 full redraws, 7 slowest frame ms, 8 seconds counted, 9 a line waits in Stt for the wire,
15note 10 bytes blitted.
16global Stw ulong 16
17global Stv ulong 16
18global Stt uchar 256
19global Sttn ulong 1
20global Stdig uchar 24
21global Stn ulong 8
22text Stfmt "STAT % s=# t=# f=# cc=# bl=# r=# px=# full=# max=# lens=#x# rip=# kb=#"
23text Stnetf "net=# e=# h=# l=# c=# p=% m=%"
24text Stkey "stats"
25fn stput c uchar to void
26n = get Sttn 0
27if lt n len Stt
28put Stt n c
29put Sttn 0 add n 1
30end
31end
32fn stnum v ulong to void
33n = ulong 0
34while gt v 9 bound 24
35put Stdig n uchar rem v 10
36v = div v 10
37n = add n 1
38end
39put Stdig n uchar v
40n = add n 1
41for i ulong n
42stput add uchar 48 get Stdig sub sub n 1 i
43end
44end
45fn stdiff a ulong b ulong to ulong
46note b - a, 0 when the clock failed or went backwards.
47if or lt b a eq b 18446744073709551615
48ret 0
49end
50ret sub b a
51end
52fn sthex v ulong to void
53note One lowercase hex digit of v (0..15).
54if lt v 10
55stput add uchar 48 uchar v
56else
57stput add uchar 87 uchar v
58end
59end
60fn stprobe h ulong to void
61note One efi 8 probe step per SNP handle (Es 15), handle 0 first; at most 16, at least one digit.
62note 0 not reached, 1 no Mode, 2 MAC size, 3 IfType, 4 Start, 5 Initialize, 6 GetStatus, 7 state,
63note 8 no link (kept initialized), 9 filter mask, a ReceiveFilters, b not opened, e chosen without
64note link detection, f chosen with a link.
65n = h
66if gt n 16
67n = ulong 16
68end
69if eq n 0
70n = ulong 1
71end
72v = get Es 15
73for i ulong n
74sthex and shr v mul i 4 15
75end
76end
77fn stnet to void
78note Stnetf from Es (efi-main.om efnetup): network ready, last firmware error, then efi 8's
79note handles, LocateHandleBuffer status, scans, probe steps and the adapter's MAC (Nmac).
80d = get Es 14
81put Stn 0 get Es 6
82put Stn 1 get Es 12
83put Stn 2 and d 255
84put Stn 3 and shr d 8 255
85put Stn 4 and shr d 16 65535
86k = ulong 0
87for i ulong len Stnetf
88c = get Stnetf i
89if eq c 35
90stnum get Stn k
91k = add k 1
92else
93if eq c 37
94if eq k 5
95stprobe get Stn 2
96else
97for j ulong 6
98b = ulong get Nmac j
99sthex shr b 4
100sthex and b 15
101end
102end
103k = add k 1
104else
105stput c
106end
107end
108end
109end
110fn stline to void
111note Stfmt with every # replaced by the next value of Stv and % by the network fields.
112put Sttn 0 0
113k = ulong 0
114for i ulong len Stfmt
115c = get Stfmt i
116if eq c 35
117stnum get Stv k
118k = add k 1
119else
120if eq c 37
121stnet
122else
123stput c
124end
125end
126end
127end
128fn stsecond now ulong t ulong to void
129put Stw 8 add get Stw 8 1
130put Stv 0 get Stw 8
131put Stv 1 t
132put Stv 2 get Stw 1
133put Stv 3 get Stw 2
134put Stv 4 get Stw 3
135put Stv 5 get Stw 4
136put Stv 6 get Stw 5
137put Stv 7 get Stw 6
138put Stv 8 get Stw 7
139put Stv 9 ulong pkmax get Ntlens 2 0
140put Stv 10 ulong pkmax get Ntlens 3 0
141put Stv 11 ulong pkmax get Ntrip 0 0
142put Stv 12 div get Stw 10 1024
143stline
144put Stw 9 1
145for i ulong 8
146put Stw i 0
147end
148put Stw 0 now
149put Stw 10 0
150end
151fn stframe t0 ulong t1 ulong t2 ulong t ulong px ulong rf ulong to void
152note One frame: t0 before the decision, t1 after compose and conversion, t2 after the blit;
153note t is the show's clock, px the pixels composed, rf twice the rectangles plus 1 for a
154note whole-screen redraw (six parameters is the language's limit).
155if eq get Stw 0 0
156put Stw 0 t0
157end
158put Stw 1 add get Stw 1 1
159put Stw 2 add get Stw 2 stdiff t0 t1
160put Stw 3 add get Stw 3 stdiff t1 t2
161put Stw 4 add get Stw 4 shr rf 1
162put Stw 5 add get Stw 5 px
163put Stw 6 add get Stw 6 and rf 1
164d = stdiff t0 t2
165if gt d get Stw 7
166put Stw 7 d
167end
168if ge t2 add get Stw 0 1000
169stsecond t2 t
170end
171end
172fn ststep up bool to void
173note Offer the waiting line to the wire when the network is up and nothing is in flight; the
174note courier's own datagrams are offered again on their clock, so one frame of delay is harmless.
175if or eq get Stw 9 0 not up
176ret
177end
178if ne get Ntxlen 0 0
179ret
180end
181n = get Sttn 0
182if or eq n 0 gt n 1472
183put Stw 9 0
184ret
185end
186ntxzero
187for i ulong n
188put Ntx add 42 i get Stt i
189end
190nudp 4294967295 47033 47033 n true
191nqueue 7 add 42 n
192put Stw 9 0
193end
194fn stasked to bool
195note True when the typed line is `stats`: the last line becomes what Allen says.
196n = get Hminn 0
197if ne n len Stkey
198ret false
199end
200for i ulong n
201if ne get Hmin i get Stkey i
202ret false
203end
204end
205n = get Sttn 0
206if gt n len Hmsay
207n = len Hmsay
208end
209for i ulong n
210put Hmsay i get Stt i
211end
212put Hmsayn 0 n
213hmsaid
214ret true
215end