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 / apps / aienos-site / om / allen-page / speed-js.om

226 lines · 50253 bytes Raw Blame History
1note AienSpeed: the live inference speed test as one self-contained browser component.
2note This unit writes public/js/aien-speed.js, which defines only window.AienSpeed =
3note {mount(el, options), unmount()}; mount builds the whole pane inside el with
4note createElement and text nodes. Each text below holds one group of functions, emitted
5note byte for byte in order. Routes, limits and the own-GPU command are defined once, in the
6note prelude text. Generated by speed-check.sh with the pinned omc of om/hive-page
7note (sha256 in om/hive-page/omc.sha256); compiled on its own, never with the chat units.
8global output uchar 65536
9global used ulong 1
10global target int 1
11
12fn flush to void
13p = ulong 0
14while lt p get used 0 bound 65536
15n = write get target 0 output p sub get used 0 p
16if le n 0
17trap 3
18end
19p = add p ulong n
20end
21put used 0 0
22end
23
24fn raw c uchar to void
25if eq get used 0 len output
26flush
27end
28put output get used 0 c
29put used 0 add get used 0 1
30end
31
32note JavaScript prelude
33text sp0 "(() => {\n 'use strict';\n /* AienSpeed: a live inference speed test, mounted into any element with\n window.AienSpeed.mount(el, options) and removed with unmount(). Every number\n comes from the gateway's own stream: tok.t is the gateway clock in ms since\n the run started, so the graph shows what the server measured, counted raw in\n BUCKET_MS windows and never smoothed. The client first token is this page's\n clock, from the Run press to the first tok event. Text reaches the page only\n through textContent and text nodes. Nothing loads from outside. */\n const PRESETS = ['short', 'medium', 'long'];\n const PRESET_NAMES = { short: 'Short', medium: 'Medium', long: 'Long' };\n const MAX_TOKENS = [64, 256, 512, 1024, 2048, 4096];\n const MAX_DEFAULT = 256;\n const PARALLEL_MAX = 1024;\n const STREAMS = [1, 2, 3, 4];\n const SWEEP_SIZES = [4096, 8192, 16384, 32768];\n const BUCKET_MS = 250;\n const HISTORY_MAX = 50;\n const PROMPT_BYTES = 49152;\n const DEFAULTS = {\n api: '/aien/api',\n model: '',\n server: \"Drake's GB10 (DGX Spark)\",\n historyKey: 'aien.speed',\n share: true,\n };\n const OWN_COMMAND = 'cd aienos.com && python3 scripts/allen/allen_infer.py bench http://127.0.0.1:8000 --model <your-model>';\n const SHARE_ADDRESS = /^#r=([A-Za-z0-9_-]{1,65536})$/;\n const OFFLINE_TEXT = 'The model is offline right now. The speed test is back when it is.';\n const OFFLINE_POLL_MS = 60000;\n let lab = null;\n let serial = 0;\n"
34
35note JavaScript helpers
36text sp1 " function h(tag, props, ...kids) {\n const node = document.createElement(tag);\n if (props) {\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined || value === null || value === false) continue;\n if (key === 'class') node.className = value;\n else if (key === 'text') node.textContent = value;\n else if (key === 'hidden') node.hidden = true;\n else node.setAttribute(key, value === true ? '' : String(value));\n }\n }\n for (const kid of kids) if (kid !== null && kid !== undefined && kid !== false) node.append(kid);\n return node;\n }\n function setText(node, value) {\n if (node && node.textContent !== value) node.textContent = value;\n }\n function cut(text, max) {\n if (text.length <= max) return text;\n const head = text.slice(0, max);\n return /[\\ud800-\\udbff]$/.test(head) ? head.slice(0, -1) : head;\n }\n function retryAfter(response, body) {\n const value = Number(body && body.retry_after !== undefined ? body.retry_after : response.headers.get('Retry-After'));\n return Number.isFinite(value) && value > 0 ? Math.ceil(value) : 0;\n }\n async function copyText(source, node) {\n if (node.dataset.label === undefined) node.dataset.label = node.textContent;\n try {\n await navigator.clipboard.writeText(source);\n setText(node, 'Copied');\n } catch (_) {\n setText(node, 'Copy blocked');\n }\n setTimeout(() => setText(node, node.dataset.label), 1500);\n }\n /* Incremental server-sent events: a chunk may end anywhere, even inside a line. */\n function sse(onEvent) {\n let carry = '';\n let name = '';\n let data = [];\n function line(text) {\n if (text === '') {\n if (data.length) onEvent(name || 'message', data.join('\\n'));\n name = '';\n data = [];\n return;\n }\n if (text.startsWith(':')) return;\n const colon = text.indexOf(':');\n const field = colon < 0 ? text : text.slice(0, colon);\n let value = colon < 0 ? '' : text.slice(colon + 1);\n if (value.startsWith(' ')) value = value.slice(1);\n if (field === 'event') name = value;\n else if (field === 'data') data.push(value);\n }\n return {\n feed(chunk) {\n carry += chunk;\n let start = 0;\n for (;;) {\n const end = carry.indexOf('\\n', start);\n if (end < 0) break;\n line(carry.slice(start, end).replace(/\\r$/, ''));\n start = end + 1;\n }\n carry = carry.slice(start);\n },\n end() {\n if (carry) line(carry.replace(/\\r$/, ''));\n carry = '';\n line('');\n },\n };\n }\n"
37
38note JavaScript build
39text sp2 " function choices(values, selected, label) {\n return values.map((value) => h('option', { value: String(value), selected: value === selected, text: label ? label(value) : String(value) }));\n }\n function build(host, options) {\n serial += 1;\n const id = (name) => `aien-speed-${serial}-${name}`;\n const presetButtons = PRESETS.map((name) => h('button', { type: 'button', class: 'sp-preset', 'data-preset': name, 'aria-pressed': 'false' },\n h('span', { class: 'sp-preset-name', text: PRESET_NAMES[name] }),\n h('span', { class: 'sp-preset-n', text: 'max tokens set by the server' })));\n const radio = (value, text, checked) => h('label', { class: 'sp-mode' },\n h('input', { type: 'radio', name: id('mode'), value, checked }), ' ', h('span', { text }));\n const streams = h('select', { 'aria-label': 'Streams' }, ...choices(STREAMS, 4));\n const sweep = h('select', { 'aria-label': 'Largest prompt' }, ...choices(SWEEP_SIZES, 4096, (size) => `${size / 1024}k`));\n const modes = h('fieldset', { class: 'sp-modes' },\n h('legend', { text: 'Mode' }),\n radio('single', 'Single', true), radio('concurrent', 'Parallel', false), radio('sweep', 'Context sweep', false),\n h('label', { class: 'sp-opt', 'data-for': 'concurrent', hidden: true }, 'Streams ', streams),\n h('label', { class: 'sp-opt', 'data-for': 'sweep', hidden: true }, 'Up to ', sweep, ' prompt tokens'));\n const prompt = h('textarea', { id: id('prompt'), rows: 3, maxlength: PROMPT_BYTES, autocomplete: 'off', placeholder: 'Or write your own prompt. An empty box runs the last preset.' });\n const max = h('select', { 'aria-label': 'Max tokens' }, ...choices(MAX_TOKENS, MAX_DEFAULT));\n const run = h('button', { type: 'button', class: 'sp-run', text: 'Run' });\n const halt = h('button', { type: 'button', class: 'sp-stop', text: 'Stop', disabled: true });\n const status = h('p', { class: 'sp-status', role: 'status', 'aria-live': 'polite' });\n const heroNumber = h('span', { class: 'sp-hero-n', text: '-' });\n const heroText = h('span', { class: 'sp-hero-t' });\n const canvas = h('canvas', { width: 940, height: 240, role: 'img', 'aria-label': 'Tokens per second since the start of the run' });\n const caption = h('figcaption', {});\n const outputs = h('div', { class: 'sp-outputs' });\n const verify = h('p', { class: 'sp-verify', hidden: true });\n const results = h('dl', { class: 'sp-results' });\n const label = h('p', { class: 'sp-label' });\n const share = h('button', { type: 'button', class: 'sp-tool', text: 'Copy share link', disabled: true });\n const clear = h('button', { type: 'button', class: 'sp-tool', text: 'Clear' });\n const history = h('table', {},\n h('thead', {}, h('tr', {}, ...['When', 'Mode', 'TTFT ms', 'Prefill tok/s', 'Decode tok/s', 'Aggregate tok/s', 'Tokens out', 'In flight', 'Load']\n .map((text) => h('th', { scope: 'col', text })))),\n h('tbody', {}));\n const own = h('code', { text: OWN_COMMAND });\n const ownCopy = h('button', { type: 'button', class: 'sp-tool', text: 'Copy' });\n const panel = h('section', { class: 'sp-panel', 'aria-label': 'Live speed test', 'data-mode': 'single', 'data-state': 'idle' },\n h('div', { class: 'sp-presets', role: 'group', 'aria-label': 'Presets: one press runs a test' }, ...presetButtons),\n modes,\n h('p', { class: 'sp-note', 'data-for': 'single concurrent', text: 'A preset runs at once, with a fixed prompt and token limit, so runs compare. Run sends your own prompt, or the last preset when the box is empty.' }),\n h('p', { class: 'sp-note', 'data-for': 'concurrent', hidden: true, text: `Parallel sends the same prompt as 1 to 4 streams at once, each capped at ${PARALLEL_MAX} tokens, and adds up their speed.` }),\n h('p', { class: 'sp-note', 'data-for': 'sweep', hidden: true, text: 'A sweep doubles the prompt from 512 tokens up to the size you pick and asks for 8 tokens each step. Every step is a cold prefill (nothing cached), so a 32k sweep takes minutes. Presets and your prompt do not apply.' }),\n h('div', { class: 'sp-compose' },\n h('label', { class: 'sp-sr', for: id('prompt'), text: 'Your own prompt' }),\n prompt,\n h('div', { class: 'sp-actions' }, h('label', { class: 'sp-max' }, 'Max tokens ', max), run, halt)),\n h('div', { class: 'sp-readout' }, status, h('p', { class: 'sp-hero', 'aria-hidden': 'true' }, heroNumber, heroText)),\n h('figure', { class: 'sp-graph' }, canvas, caption),\n outputs,\n h('section', { class: 'sp-box', 'aria-label': 'Result of the run' },\n h('h3', { class: 'sp-h', text: 'Result' }), verify, results, label, h('p', { class: 'sp-share' }, share)),\n h('section', { class: 'sp-box', 'aria-label': 'Your runs' },\n h('h3', { class: 'sp-h' }, 'Your runs ', clear),\n h('div', { class: 'sp-table' }, history),\n h('p', { class: 'sp-note', text: `Kept only in this browser, newest first, at most ${HISTORY_MAX} runs. Clear removes them.` })),\n h('section', { class: 'sp-box', 'aria-label': 'Run this on your own GPU' },\n h('h3', { class: 'sp-h', text: 'Run this on your own GPU' }),\n h('div', { class: 'sp-cmd' }, own, ownCopy),\n h('p', { class: 'sp-note', text: 'From a copy of the aienos.com repository, which is moving to Interplane (downloads are not open yet). Same presets and the same measurement code as this page, against any OpenAI-compatible server.' })));\n host.classList.add('aien-speed');\n host.replaceChildren(panel);\n return {\n host, options, panel, presetButtons, modes, prompt, max, run, halt, streams, sweep, status, heroNumber, heroText, canvas,\n caption, outputs, verify, results, label, share, clear, history, own, ownCopy,\n routes: { infer: `${options.api}/infer`, verify: `${options.api}/infer-verify`, info: `${options.api}/infer-info` },\n preset: 'short', info: null, active: null, view: null, shared: null, link: '', timer: 0, frame: 0,\n offline: false, poll: 0, off: [],\n };\n }\n"
40
41note JavaScript format
42text sp3 " function labNumber(value) {\n return typeof value === 'number' && Number.isFinite(value) ? value : NaN;\n }\n function labRate(value) {\n const number = labNumber(value);\n return Number.isNaN(number) ? '-' : number.toFixed(1);\n }\n function labMs(value) {\n const number = labNumber(value);\n return Number.isNaN(number) ? '-' : String(Math.round(number));\n }\n function labWord(value, size) {\n return typeof value === 'string' || typeof value === 'number' ? String(value).slice(0, size) : '-';\n }\n function labModeName(mode) {\n return { single: 'Single', concurrent: 'Parallel', sweep: 'Context sweep' }[mode] || 'Unknown';\n }\n function labList(result) {\n const list = Array.isArray(result.streams_out) ? result.streams_out : [];\n return list.filter((item) => item && typeof item === 'object').slice(0, 64);\n }\n function labEach(list, key, format) {\n return list.length ? list.map((item) => format(item[key])).join(' / ') : '-';\n }\n function labSlots() {\n return lab.info && Number.isSafeInteger(lab.info.slots) ? lab.info.slots : 4;\n }\n function labSize(tokens) {\n return tokens >= 1024 && tokens % 1024 === 0 ? `${tokens / 1024}k` : String(tokens);\n }\n"
43
44note JavaScript say
45text sp4 " function labSay(text, wait) {\n clearInterval(lab.timer);\n if (!wait) {\n setText(lab.status, text);\n return;\n }\n let left = wait;\n const show = () => setText(lab.status, left > 0 ? `${text}: busy, try again in ${left} s.` : `${text}. You can try again now.`);\n show();\n lab.timer = setInterval(() => {\n left -= 1;\n show();\n if (left <= 0) clearInterval(lab.timer);\n }, 1000);\n }\n function labRefusal(status, reply) {\n const code = reply && typeof reply.error === 'string' ? reply.error : '';\n const limits = lab.info && lab.info.limits && typeof lab.info.limits === 'object' ? lab.info.limits : {};\n if (code === 'offline') return OFFLINE_TEXT;\n if (status === 503 || code === 'busy') return 'Every test slot is taken';\n if (status === 429 || code === 'rate') {\n const runs = Number.isSafeInteger(limits.runs_per_min) ? limits.runs_per_min : 6;\n const heavy = Number.isSafeInteger(limits.heavy_per_10min) ? limits.heavy_per_10min : 3;\n return `That is more runs than the limit (${runs} a minute, ${heavy} heavy tests in 10 minutes)`;\n }\n if (status === 409 || code === 'one_at_a_time') return 'You already have a test running, maybe in another tab. Let it finish first';\n if (status === 413 || code === 'too_long') return 'That prompt is too long: at most 48 KiB and about 32768 tokens';\n if (status === 400 || code === 'bad_request') return `The gateway could not read that request${reply && typeof reply.message === 'string' ? `: ${reply.message.slice(0, 200)}` : ''}`;\n return `The speed test is not answering right now (HTTP ${status})`;\n }\n function labIdle() {\n const info = lab.info;\n if (!info || lab.active || lab.shared || lab.offline) return;\n const busy = Number.isSafeInteger(info.tests_in_flight) ? info.tests_in_flight : 0;\n const queue = Number.isSafeInteger(info.queue) ? info.queue : 0;\n labSay(`Ready. ${busy} of ${labSlots()} test slots busy${queue ? `, ${queue} in line` : ''}. Press a preset.`);\n }\n function labLabel(source) {\n const model = typeof source.model === 'string' && source.model ? source.model.slice(0, 80) : lab.options.model;\n const flight = source.server_in_flight;\n let text = `Live shared server: ${lab.options.server}${model ? `, ${model}` : ''}. Numbers vary with load`;\n if (Number.isSafeInteger(flight)) text += `; ${flight} ${flight === 1 ? 'request was' : 'requests were'} in flight on the server when this run started`;\n if (!Number.isNaN(labNumber(source.load1))) text += `, host load ${source.load1}`;\n setText(lab.label, `${text}.`);\n }\n function labCaption(sweep) {\n setText(lab.caption, sweep\n ? 'Prefill tokens per second against prompt tokens (log2 scale), one point per step, from the server count: raw, no smoothing.'\n : `Tokens per second against seconds since the start, one line per stream: raw, ${BUCKET_MS} ms buckets, no smoothing.`);\n lab.canvas.setAttribute('aria-label', sweep ? 'Prefill tokens per second for each prompt size' : 'Tokens per second since the start of the run');\n }\n"
46
47note JavaScript modes
48text sp5 " function labMode() {\n const pick = lab.modes.querySelector('input[type=\"radio\"]:checked');\n return pick ? pick.value : 'single';\n }\n function labModeShow() {\n const mode = labMode();\n lab.panel.dataset.mode = mode;\n for (const node of lab.panel.querySelectorAll('[data-for]')) node.hidden = !node.dataset.for.split(' ').includes(mode);\n for (const option of lab.max.options) option.disabled = mode === 'concurrent' && Number(option.value) > PARALLEL_MAX;\n if (mode === 'concurrent' && Number(lab.max.value) > PARALLEL_MAX) lab.max.value = String(PARALLEL_MAX);\n lab.max.disabled = mode === 'sweep' || Boolean(lab.active);\n lab.prompt.disabled = mode === 'sweep';\n for (const item of lab.presetButtons) item.disabled = Boolean(lab.active) || lab.offline || mode === 'sweep';\n lab.run.disabled = Boolean(lab.active) || lab.offline;\n }\n function labBusy(on) {\n lab.panel.dataset.state = on ? 'running' : lab.offline ? 'offline' : 'idle';\n lab.halt.disabled = !on;\n for (const input of lab.modes.querySelectorAll('input, select')) input.disabled = on;\n labModeShow();\n }\n"
49
50note JavaScript info
51text sp6 " /* While the model is down, infer-info says server_ok false: the pane says so,\n turns its run controls off, and asks again every OFFLINE_POLL_MS. */\n function labOffline(on) {\n lab.offline = on;\n clearTimeout(lab.poll);\n lab.poll = on ? setTimeout(labInfo, OFFLINE_POLL_MS) : 0;\n if (!lab.active) labBusy(false);\n if (on && !lab.shared) labSay(OFFLINE_TEXT);\n labPaint();\n }\n async function labInfo() {\n const mine = lab;\n try {\n const response = await fetch(mine.routes.info, { cache: 'no-store', credentials: 'omit' });\n if (!response.ok) return;\n const info = await response.json();\n if (lab !== mine || !info || typeof info !== 'object') return;\n lab.info = info;\n const presets = info.presets && typeof info.presets === 'object' ? info.presets : {};\n for (const item of lab.presetButtons) {\n const preset = presets[item.dataset.preset];\n if (!preset || typeof preset !== 'object') continue;\n if (Number.isSafeInteger(preset.max_tokens)) setText(item.querySelector('.sp-preset-n'), `${preset.max_tokens} tokens`);\n if (typeof preset.prompt === 'string') item.title = cut(preset.prompt, 300);\n }\n if (info.server_ok === false) {\n labOffline(true);\n return;\n }\n if (lab.offline) labOffline(false);\n labIdle();\n } catch (_) {\n /* The presets still run with the server's own numbers. */\n }\n }\n"
52
53note JavaScript lanes
54text sp7 " function labView(mode) {\n return {\n mode, click: performance.now(), first: NaN, start: null, done: null, yielded: null,\n outcome: '', tokens: 0, series: [], lanes: [], marks: [], steps: [], stepAt: 0,\n };\n }\n function labLaneName(view, index) {\n if (view.mode === 'sweep') {\n const size = view.steps[index];\n return `Step ${index + 1}${Number.isSafeInteger(size) ? `: ${labSize(size)} prompt tokens` : ''}`;\n }\n return view.mode === 'single' ? 'Output' : `Stream ${index + 1}`;\n }\n function labLane(view, index) {\n while (view.lanes.length <= index) {\n const number = view.lanes.length;\n const tally = h('span', { class: 'sp-out-tally' });\n const text = h('pre', { class: 'sp-text' });\n const stats = h('p', { class: 'sp-out-stats' });\n lab.outputs.append(h('div', { class: view.mode === 'sweep' ? 'sp-step' : 'sp-out', 'data-lane': number % 4 },\n h('p', { class: 'sp-out-head' }, h('span', { class: 'sp-out-name', text: labLaneName(view, number) }), tally),\n text, stats));\n view.lanes.push({ text, tally, stats, buf: '', shown: 0, count: 0, stat: null });\n }\n return view.lanes[index];\n }\n function labStat(stat, mode) {\n const parts = [];\n if (mode === 'sweep') parts.push(`${labWord(stat.prompt_tokens, 12)} prompt tokens`);\n parts.push(`first token ${labMs(stat.ttft_ms)} ms`);\n parts.push(`prefill ${labRate(stat.prefill_tps)} tok/s`);\n if (mode !== 'sweep') parts.push(`decode ${labRate(stat.decode_tps)} tok/s`);\n parts.push(`${labWord(stat.completion_tokens, 12)} tokens out in ${labMs(stat.total_ms)} ms`);\n if (typeof stat.finish === 'string') parts.push(`finish ${stat.finish.slice(0, 24)}`);\n return parts.join(', ');\n }\n"
55
56note JavaScript rows
57text sp8 " function labRows(result, view) {\n const list = labList(result);\n const streams = Number.isSafeInteger(result.streams) && result.streams > 1 ? `, ${result.streams} streams` : '';\n const max = Number.isSafeInteger(result.max_tokens) && result.mode !== 'sweep' ? `, max ${result.max_tokens} tokens` : '';\n let client = 'not in a shared link';\n if (view) client = Number.isNaN(view.first) ? '-' : `${Math.round(view.first - view.click)} ms`;\n const rows = [\n ['Mode', `${labModeName(result.mode)}${streams}${max}${result.yielded === true ? ', yielded to a live chat' : ''}`],\n ['First token, server (ms)', labEach(list, 'ttft_ms', labMs)],\n ['First token, from Run', client],\n ['Prefill tok/s', labEach(list, 'prefill_tps', labRate)],\n ['Decode tok/s', labEach(list, 'decode_tps', labRate)],\n ['Total (ms)', `${labEach(list, 'total_ms', labMs)}${Number.isNaN(labNumber(result.wall_ms)) ? '' : `, wall ${labMs(result.wall_ms)}`}`],\n ['Tokens in / out', list.length ? list.map((item) => `${labWord(item.prompt_tokens, 12)} / ${labWord(item.completion_tokens, 12)}`).join(', ') : '-'],\n ];\n if (result.mode === 'concurrent') rows.push(['Aggregate tok/s', labRate(result.aggregate_tps)]);\n rows.push(['Server requests in flight at start', labWord(result.server_in_flight, 12)]);\n rows.push(['Test slots in use', `${labWord(result.tests_in_flight, 12)} of ${labSlots()}`]);\n rows.push(['Host load (1 min)', labWord(result.load1, 12)]);\n if (typeof result.run === 'string' && result.run) rows.push(['Run', `${result.run.slice(0, 40)}${typeof result.utc === 'string' && result.utc ? ` at ${result.utc.slice(0, 40)}` : ''}`]);\n return rows;\n }\n function labResult(result, view) {\n lab.results.replaceChildren(...labRows(result, view).map(([name, value]) => h('div', { class: 'sp-stat' }, h('dt', { text: name }), h('dd', { text: value }))));\n labLabel(result);\n }\n function labPartial(view) {\n const start = view.start || {};\n return {\n mode: view.mode, model: start.model, run: start.run, streams: start.streams,\n max_tokens: start.max_tokens, server_in_flight: start.server_in_flight,\n tests_in_flight: start.tests_in_flight, load1: start.load1,\n streams_out: view.lanes.map((lane) => lane.stat).filter(Boolean),\n };\n }\n"
58
59note JavaScript history
60text sp9 " function historyRead() {\n try {\n const rows = JSON.parse(localStorage.getItem(lab.options.historyKey) || '[]');\n return Array.isArray(rows) ? rows.filter((row) => row && typeof row === 'object').slice(0, HISTORY_MAX) : [];\n } catch (_) {\n return [];\n }\n }\n function historyWrite(rows) {\n try {\n localStorage.setItem(lab.options.historyKey, JSON.stringify(rows.slice(0, HISTORY_MAX)));\n } catch (_) {\n /* A full or blocked store keeps the table as it was. */\n }\n }\n function historyClear() {\n try {\n localStorage.removeItem(lab.options.historyKey);\n } catch (_) {\n /* Nothing stored. */\n }\n historyShow();\n }\n function historyAdd(result, link) {\n const list = labList(result);\n const streams = Number.isSafeInteger(result.streams) && result.streams > 1 ? ` x${result.streams}` : '';\n const out = list.reduce((sum, item) => sum + (Number.isSafeInteger(item.completion_tokens) ? item.completion_tokens : 0), 0);\n historyWrite([{\n when: typeof result.utc === 'string' ? result.utc.slice(0, 40) : new Date().toISOString(),\n mode: `${labModeName(result.mode)}${streams}${result.yielded === true ? ' (yielded)' : ''}`,\n ttft: labEach(list, 'ttft_ms', labMs),\n prefill: labEach(list, 'prefill_tps', labRate),\n decode: result.mode === 'sweep' ? '-' : labEach(list, 'decode_tps', labRate),\n agg: result.mode === 'concurrent' ? labRate(result.aggregate_tps) : '-',\n out: String(out),\n inflight: labWord(result.server_in_flight, 12),\n load: labWord(result.load1, 12),\n share: link,\n }, ...historyRead()]);\n historyShow();\n }\n function historyShow() {\n const body = lab.history.tBodies[0];\n const rows = historyRead();\n body.replaceChildren(...rows.map((row) => {\n const stamp = labWord(row.when, 40).replace('T', ' ').slice(0, 19);\n const shared = lab.options.share && typeof row.share === 'string' && /^[A-Za-z0-9_-]{1,65536}$/.test(row.share);\n const when = h('td', {}, shared ? h('a', { href: `#r=${row.share}`, text: stamp }) : stamp);\n return h('tr', {}, when, ...['mode', 'ttft', 'prefill', 'decode', 'agg', 'out', 'inflight', 'load'].map((key) => h('td', { text: labWord(row[key], 200) })));\n }));\n if (!rows.length) body.append(h('tr', {}, h('td', { class: 'sp-empty', colspan: 9, text: 'No runs yet. Your runs appear here, kept only in this browser.' })));\n lab.clear.disabled = !rows.length;\n }\n"
61
62note JavaScript share
63text sp10 " function labPack(text) {\n let binary = '';\n for (const byte of new TextEncoder().encode(text)) binary += String.fromCharCode(byte);\n return btoa(binary).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n }\n function labUnpack(text) {\n const plain = text.replace(/-/g, '+').replace(/_/g, '/');\n const binary = atob(plain + '='.repeat((4 - (plain.length % 4)) % 4));\n const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));\n return new TextDecoder('utf-8', { fatal: true }).decode(bytes);\n }\n function labVerdict(verdict) {\n lab.verify.hidden = false;\n lab.verify.dataset.state = verdict === true ? 'ok' : verdict === false ? 'bad' : 'unknown';\n setText(lab.verify, verdict === true\n ? 'Verified: produced by this gateway'\n : verdict === false\n ? 'Not verified: this link was edited or is from another server'\n : 'Not checked: the gateway did not answer. Open the link again later.');\n }\n async function labShared() {\n const match = SHARE_ADDRESS.exec(location.hash);\n if (!lab.options.share || !match || lab.active) return;\n const mine = lab;\n let payload = null;\n try {\n payload = JSON.parse(labUnpack(match[1]));\n } catch (_) {\n payload = null;\n }\n lab.view = null;\n lab.link = '';\n lab.share.disabled = true;\n lab.outputs.replaceChildren();\n const readable = payload && typeof payload === 'object' && payload.result && typeof payload.result === 'object'\n && !Array.isArray(payload.result) && typeof payload.sig === 'string' && /^[0-9a-f]{16,256}$/.test(payload.sig);\n if (!readable) {\n lab.shared = null;\n lab.results.replaceChildren();\n labVerdict(false);\n labSay('This share link could not be read.');\n labDirty();\n return;\n }\n lab.shared = payload;\n const result = payload.result;\n labResult(result, null);\n labCaption(result.mode === 'sweep');\n labSay(`Showing a shared run${typeof result.utc === 'string' ? ` from ${result.utc.slice(0, 40)}` : ''}. Press a preset to run your own.`);\n lab.verify.hidden = false;\n lab.verify.dataset.state = 'checking';\n setText(lab.verify, 'Checking this link with the gateway.');\n labDirty();\n let verdict = null;\n try {\n const response = await fetch(mine.routes.verify, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ result, sig: payload.sig }),\n cache: 'no-store',\n credentials: 'omit',\n });\n if (response.status < 500) {\n const reply = await response.json().catch(() => null);\n verdict = Boolean(response.ok && reply && reply.ok === true);\n }\n } catch (_) {\n verdict = null;\n }\n if (lab === mine && lab.shared === payload) labVerdict(verdict);\n }\n function labCopyLink() {\n if (lab.link) copyText(`${location.origin}${location.pathname}${location.search}#r=${lab.link}`, lab.share);\n }\n"
64
65note JavaScript event
66text sp11 " function labEvent(name, data, view) {\n let value;\n try {\n value = JSON.parse(data);\n } catch (_) {\n return;\n }\n if (!value || typeof value !== 'object') return;\n if (name === 'queue') {\n if (value.reason === 'chat') labSay('Waiting: a live chat is running; tests yield to chat.');\n else labSay(`In line: position ${labWord(value.position, 6)}, ${labWord(value.tests_in_flight, 6)} of ${labWord(value.slots, 6)} test slots busy.`);\n } else if (name === 'start') {\n view.start = value;\n view.steps = Array.isArray(value.steps) ? value.steps.filter(Number.isSafeInteger).slice(0, 16) : [];\n const lanes = view.mode === 'sweep' ? view.steps.length : Number.isSafeInteger(value.streams) ? Math.min(value.streams, 4) : 1;\n for (let index = 0; index < Math.max(lanes, 1); index += 1) labLane(view, index);\n labResult(labPartial(view), view);\n labSay(view.mode === 'sweep'\n ? `Sweep running: ${view.steps.length} steps, up to ${labSize(view.steps[view.steps.length - 1] || 0)} prompt tokens.`\n : 'Running: reading the prompt, waiting for the first token.');\n } else if (name === 'tok') {\n const index = value.i;\n const time = labNumber(value.t);\n if (!Number.isSafeInteger(index) || index < 0 || index > 15 || Number.isNaN(time) || time < 0) return;\n if (Number.isNaN(view.first)) {\n view.first = performance.now();\n labResult(labPartial(view), view);\n if (view.mode !== 'sweep') labSay('Streaming.');\n }\n view.tokens += 1;\n const lane = labLane(view, index);\n if (typeof value.s === 'string') lane.buf += value.s;\n lane.count += 1;\n if (view.mode !== 'sweep') {\n const bucket = Math.floor(time / BUCKET_MS);\n const series = view.series[index] || (view.series[index] = []);\n while (series.length <= bucket) series.push(0);\n series[bucket] += 1;\n }\n labDirty();\n } else if (name === 'stream') {\n const index = Number.isSafeInteger(value.i) && value.i >= 0 && value.i <= 15 ? value.i : view.lanes.length;\n labLane(view, index).stat = value;\n const started = labNumber(value.start_ms);\n const total = labNumber(value.total_ms);\n if (!Number.isNaN(started) && !Number.isNaN(total)) view.stepAt = Math.max(view.stepAt, started + total);\n const tokens = value.prompt_tokens;\n const rate = labNumber(value.prefill_tps);\n if (view.mode === 'sweep' && Number.isSafeInteger(tokens) && tokens > 0 && !Number.isNaN(rate)) view.marks.push({ x: tokens, y: rate });\n labResult(labPartial(view), view);\n if (view.mode === 'sweep' && view.marks.length < view.steps.length) labSay(`Step ${view.marks.length + 1} of ${view.steps.length}: prefilling.`);\n labDirty();\n } else if (name === 'beat') {\n const time = labNumber(value.t);\n const seconds = Number.isNaN(time) ? 0 : Math.max(0, Math.round((time - view.stepAt) / 1000));\n labSay(view.mode === 'sweep'\n ? `Step ${Math.min(view.marks.length + 1, view.steps.length || 1)} of ${view.steps.length || 1}: prefilling, ${seconds} s.`\n : `Prefilling, ${seconds} s.`);\n } else if (name === 'yielded') {\n view.yielded = value;\n labSay(`Yielded to a live chat after ${labWord(value.completed_steps, 6)} completed steps.`);\n } else if (name === 'done') {\n const result = value.result;\n if (!result || typeof result !== 'object' || Array.isArray(result)) return;\n view.done = value;\n labResult(result, view);\n lab.link = typeof value.sig === 'string' ? labPack(JSON.stringify({ result, sig: value.sig })) : '';\n lab.share.disabled = !lab.link || !lab.options.share;\n historyAdd(result, lab.link);\n } else if (name === 'error') {\n view.outcome = `The run stopped with an error: ${labWord(value.message || value.code, 200)}`;\n }\n }\n"
67
68note JavaScript run
69text sp12 " function labBody(preset) {\n const mode = labMode();\n const body = { mode };\n if (mode === 'sweep') {\n body.sweep_max = Number(lab.sweep.value);\n return body;\n }\n const text = lab.prompt.value.trim() ? lab.prompt.value : '';\n if (preset || !text) {\n body.preset = preset || lab.preset;\n } else {\n body.prompt = text;\n body.max_tokens = Number(lab.max.value);\n }\n if (mode === 'concurrent') body.streams = Number(lab.streams.value);\n return body;\n }\n async function labRun(preset) {\n if (!lab || lab.active || lab.offline) return;\n const body = labBody(preset);\n if (body.prompt !== undefined) {\n const bytes = new TextEncoder().encode(body.prompt).length;\n if (bytes > PROMPT_BYTES) {\n labSay(`Your prompt is ${bytes} bytes; the limit is ${PROMPT_BYTES} bytes.`);\n return;\n }\n }\n if (body.preset) lab.preset = body.preset;\n for (const item of lab.presetButtons) item.setAttribute('aria-pressed', String(Boolean(body.preset) && item.dataset.preset === body.preset));\n if (SHARE_ADDRESS.test(location.hash)) history.replaceState(null, '', `${location.pathname}${location.search}`);\n lab.shared = null;\n lab.verify.hidden = true;\n lab.link = '';\n lab.share.disabled = true;\n lab.outputs.replaceChildren();\n lab.results.replaceChildren();\n const mine = lab;\n const view = labView(body.mode);\n lab.view = view;\n const controller = new AbortController();\n lab.active = controller;\n labBusy(true);\n labCaption(body.mode === 'sweep');\n labSay('Sending.');\n labPaint();\n let wait = 0;\n let offline = false;\n try {\n const response = await fetch(mine.routes.infer, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', Accept: 'text/event-stream' },\n body: JSON.stringify(body),\n cache: 'no-store',\n credentials: 'omit',\n signal: controller.signal,\n });\n const type = response.headers.get('Content-Type') || '';\n if (!response.ok) {\n const reply = await response.json().catch(() => null);\n wait = retryAfter(response, reply);\n offline = Boolean(reply && reply.error === 'offline');\n view.outcome = labRefusal(response.status, reply);\n } else if (!response.body || !type.includes('text/event-stream')) {\n view.outcome = 'The gateway answered in a form this page does not read.';\n } else {\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n const parser = sse((name, data) => {\n if (lab === mine) labEvent(name, data, view);\n });\n for (;;) {\n const { value, done } = await reader.read();\n if (done) break;\n parser.feed(decoder.decode(value, { stream: true }));\n }\n parser.feed(decoder.decode());\n parser.end();\n if (!view.done && !view.outcome) view.outcome = 'The connection closed before the run finished.';\n }\n } catch (_) {\n view.outcome = controller.signal.aborted\n ? 'Stopped. The partial output stays above; a stopped run has no signed result.'\n : 'Could not reach the gateway. Check your connection and try again.';\n }\n if (lab !== mine) return;\n lab.active = null;\n labBusy(false);\n labPaint();\n if (offline) labOffline(true);\n else if (view.outcome) labSay(view.outcome, wait);\n else if (view.yielded) labSay('Yielded to a live chat: the numbers below are partial.');\n else labSay(lab.options.share ? 'Done. Copy the share link to show someone these exact numbers.' : 'Done.');\n }\n"
70
71note JavaScript paint
72text sp13 " function labDirty() {\n if (lab && !lab.frame) lab.frame = requestAnimationFrame(labPaint);\n }\n function labPaint() {\n if (!lab) return;\n if (lab.frame) cancelAnimationFrame(lab.frame);\n lab.frame = 0;\n const view = lab.view;\n if (view) {\n for (const lane of view.lanes) {\n if (lane.shown !== lane.buf.length) {\n lane.text.textContent = lane.buf;\n lane.shown = lane.buf.length;\n lane.text.scrollTop = lane.text.scrollHeight;\n }\n setText(lane.tally, lane.count ? `${lane.count} ${lane.count === 1 ? 'token' : 'tokens'}` : '');\n if (lane.stat) setText(lane.stats, labStat(lane.stat, view.mode));\n }\n }\n labHero();\n labDraw();\n }\n /* The big number: live tok/s over the last full second of buckets while a run\n streams, then the run's own headline figure from the server's result. */\n function labHero() {\n const view = lab.view;\n const result = view && view.done ? view.done.result : lab.shared ? lab.shared.result : null;\n let value = NaN;\n let text = 'tok/s shows here as the first token lands';\n if (result) {\n const list = labList(result);\n if (result.mode === 'concurrent') {\n value = labNumber(result.aggregate_tps);\n text = `aggregate tok/s over ${list.length} streams`;\n } else if (result.mode === 'sweep') {\n value = list.reduce((most, item) => Math.max(most, Number.isNaN(labNumber(item.prefill_tps)) ? 0 : item.prefill_tps), 0) || NaN;\n text = 'peak prefill tok/s';\n } else {\n value = list.length ? labNumber(list[0].decode_tps) : NaN;\n text = 'decode tok/s';\n }\n } else if (view && view.mode === 'sweep') {\n const mark = view.marks[view.marks.length - 1];\n if (mark) {\n value = mark.y;\n text = 'prefill tok/s, last step';\n }\n } else if (view) {\n const last = view.series.reduce((most, line) => Math.max(most, line ? line.length - 1 : 0), 0);\n const from = Math.max(0, last - 4);\n if (last > 0) {\n let count = 0;\n for (const line of view.series) if (line) for (let bucket = from; bucket < last; bucket += 1) count += line[bucket] || 0;\n value = (count * 1000) / ((last - from) * BUCKET_MS);\n text = view.mode === 'concurrent' ? 'tok/s right now, all streams' : 'tok/s right now';\n }\n }\n setText(lab.heroNumber, labRate(value));\n setText(lab.heroText, text);\n }\n function labStep(span, parts) {\n const raw = span / parts;\n const power = Math.pow(10, Math.floor(Math.log10(raw)));\n for (const scale of [1, 2, 5]) if (scale * power >= raw) return scale * power;\n return 10 * power;\n }\n function labTop(peak) {\n const step = labStep(peak > 0 ? peak : 10, 4);\n return { top: Math.max(step, Math.ceil(peak / step) * step), step };\n }\n"
73
74note JavaScript axes
75text sp14 " function labAxes(g, box, xs, ys, names, ink, faint) {\n g.lineWidth = 1;\n g.strokeStyle = faint;\n g.fillStyle = ink;\n g.textAlign = 'right';\n g.textBaseline = 'middle';\n for (const [text, y] of ys) {\n g.beginPath();\n g.moveTo(box.l, y);\n g.lineTo(box.r, y);\n g.stroke();\n g.fillText(text, box.l - 6, y);\n }\n g.textAlign = 'center';\n g.textBaseline = 'top';\n for (const [text, x] of xs) {\n g.beginPath();\n g.moveTo(x, box.b);\n g.lineTo(x, box.b + 4);\n g.stroke();\n g.fillText(text, x, box.b + 6);\n }\n g.fillText(names[0], (box.l + box.r) / 2, box.b + 20);\n g.save();\n g.translate(11, (box.t + box.b) / 2);\n g.rotate(-Math.PI / 2);\n g.textBaseline = 'middle';\n g.fillText(names[1], 0, 0);\n g.restore();\n }\n function labEmpty(g, box, text, ink) {\n g.fillStyle = ink;\n g.textAlign = 'center';\n g.textBaseline = 'middle';\n g.fillText(text, (box.l + box.r) / 2, (box.t + box.b) / 2);\n }\n"
76
77note JavaScript draw
78text sp15 " function labDraw() {\n const canvas = lab.canvas;\n if (!canvas.isConnected || !canvas.clientWidth) return;\n const width = Math.max(240, Math.round(canvas.clientWidth));\n const height = Math.max(160, Math.round(canvas.clientHeight || 240));\n const ratio = Math.min(window.devicePixelRatio || 1, 2);\n if (canvas.width !== Math.round(width * ratio)) canvas.width = Math.round(width * ratio);\n if (canvas.height !== Math.round(height * ratio)) canvas.height = Math.round(height * ratio);\n const g = canvas.getContext('2d');\n if (!g) return;\n g.setTransform(ratio, 0, 0, ratio, 0, 0);\n g.clearRect(0, 0, width, height);\n const css = getComputedStyle(lab.host);\n const color = (name) => css.getPropertyValue(name).trim() || 'gray';\n const colors = [color('--speed-lane-1'), color('--speed-lane-2'), color('--speed-lane-3'), color('--speed-lane-4')];\n g.font = `${width < 420 ? 10 : 11}px ${css.getPropertyValue('--speed-mono').trim() || 'monospace'}`;\n const box = { l: 52, r: width - 12, t: 12, b: height - 36 };\n const ink = color('--speed-muted');\n const faint = color('--speed-line');\n const view = lab.view;\n const shared = lab.shared ? lab.shared.result : null;\n const mode = view ? view.mode : shared ? shared.mode : labMode();\n if (mode === 'sweep') {\n let marks = view ? view.marks : [];\n let steps = view ? view.steps : [];\n if (!view && shared) {\n const list = labList(shared);\n marks = list.filter((item) => Number.isSafeInteger(item.prompt_tokens) && item.prompt_tokens > 0 && !Number.isNaN(labNumber(item.prefill_tps)))\n .map((item) => ({ x: item.prompt_tokens, y: item.prefill_tps }));\n steps = list.map((item) => item.target_tokens).filter(Number.isSafeInteger);\n }\n labSweepDraw(g, box, marks, steps, colors, ink, faint, color('--speed-fg'));\n } else {\n labRateDraw(g, box, view, colors, ink, faint, Boolean(shared));\n }\n }\n"
79
80note JavaScript ratedraw
81text sp16 " function labRateDraw(g, box, view, colors, ink, faint, shared) {\n const series = view ? view.series : [];\n let buckets = 0;\n let peak = 0;\n for (const line of series) {\n if (!line) continue;\n buckets = Math.max(buckets, line.length);\n for (const value of line) peak = Math.max(peak, value);\n }\n const seconds = Math.max(2, Math.ceil((buckets * BUCKET_MS) / 1000));\n const { top, step } = labTop((peak * 1000) / BUCKET_MS);\n const xAt = (second) => box.l + ((box.r - box.l) * second) / seconds;\n const yAt = (rate) => box.b - ((box.b - box.t) * rate) / top;\n const xs = [];\n const xStep = labStep(seconds, box.r - box.l < 360 ? 4 : 8);\n for (let second = 0; second <= seconds + 1e-9; second += xStep) xs.push([String(Math.round(second * 10) / 10), xAt(second)]);\n const ys = [];\n for (let rate = 0; rate <= top + 1e-9; rate += step) ys.push([String(Math.round(rate * 10) / 10), yAt(rate)]);\n labAxes(g, box, xs, ys, ['seconds since start', 'tok/s'], ink, faint);\n series.forEach((line, index) => {\n if (!line || !line.length) return;\n g.strokeStyle = colors[index % colors.length];\n g.lineWidth = 1.6;\n g.beginPath();\n g.moveTo(xAt(0), yAt(0));\n for (let bucket = 0; bucket < line.length; bucket += 1) {\n const rate = (line[bucket] * 1000) / BUCKET_MS;\n g.lineTo(xAt((bucket * BUCKET_MS) / 1000), yAt(rate));\n g.lineTo(xAt(((bucket + 1) * BUCKET_MS) / 1000), yAt(rate));\n }\n g.stroke();\n });\n if (series.filter(Boolean).length > 1) {\n g.textAlign = 'left';\n g.textBaseline = 'middle';\n series.forEach((line, index) => {\n const x = box.r - 70;\n const y = box.t + 8 + index * 15;\n g.fillStyle = colors[index % colors.length];\n g.fillRect(x, y - 2, 12, 4);\n g.fillText(`Stream ${index + 1}`, x + 16, y);\n });\n }\n if (!buckets) labEmpty(g, box, shared ? 'A shared link carries the result, not the token timeline.' : lab.offline ? 'Offline: the graph fills in when the model is back.' : 'Press a preset: each token is drawn as it arrives.', ink);\n }\n"
82
83note JavaScript sweepdraw
84text sp17 " function labSweepDraw(g, box, marks, steps, colors, ink, faint, fg) {\n const sizes = [...new Set([...steps, ...marks.map((mark) => mark.x)].filter((size) => size > 0))].sort((a, b) => a - b);\n const low = Math.log2(sizes.length ? sizes[0] : 512) - 0.5;\n const high = Math.log2(sizes.length ? sizes[sizes.length - 1] : Number(lab.sweep.value)) + 0.5;\n const peak = marks.reduce((most, mark) => Math.max(most, mark.y), 0);\n const { top, step } = labTop(peak);\n const xAt = (size) => box.l + ((box.r - box.l) * (Math.log2(size) - low)) / (high - low);\n const yAt = (rate) => box.b - ((box.b - box.t) * rate) / top;\n const ticks = sizes.length ? sizes.filter((size) => steps.includes(size) || !steps.length) : [512, 1024, 2048, 4096];\n const xs = ticks.map((size) => [labSize(size), xAt(size)]);\n const ys = [];\n for (let rate = 0; rate <= top + 1e-9; rate += step) ys.push([String(Math.round(rate * 10) / 10), yAt(rate)]);\n labAxes(g, box, xs, ys, ['prompt tokens (log2 scale)', 'prefill tok/s'], ink, faint);\n g.textAlign = 'center';\n g.textBaseline = 'bottom';\n for (const mark of marks) {\n const x = xAt(mark.x);\n const y = yAt(mark.y);\n g.fillStyle = colors[0];\n g.beginPath();\n g.arc(x, y, 4, 0, Math.PI * 2);\n g.fill();\n g.fillStyle = fg;\n g.fillText(mark.y.toFixed(1), x, y - 6);\n }\n if (!marks.length) labEmpty(g, box, 'Each finished step adds one point: prompt size against prefill speed.', ink);\n }\n"
85
86note JavaScript mount
87text sp18 " function listen(target, type, handler) {\n target.addEventListener(type, handler);\n lab.off.push(() => target.removeEventListener(type, handler));\n }\n function settings(given) {\n const options = { ...DEFAULTS };\n if (given && typeof given === 'object') {\n if (typeof given.api === 'string' && /^(\\/|https:\\/\\/)[^\\s]*$/.test(given.api)) options.api = given.api.replace(/\\/+$/, '');\n for (const key of ['model', 'server', 'historyKey']) if (typeof given[key] === 'string' && given[key]) options[key] = given[key].slice(0, 120);\n if (typeof given.share === 'boolean') options.share = given.share;\n }\n return options;\n }\n function mount(host, given) {\n if (!(host instanceof Element)) throw new TypeError('AienSpeed.mount needs an element');\n unmount();\n lab = build(host, settings(given));\n for (const item of lab.presetButtons) listen(item, 'click', () => labRun(item.dataset.preset));\n listen(lab.run, 'click', () => labRun(''));\n listen(lab.halt, 'click', () => {\n if (lab.active) lab.active.abort();\n });\n listen(lab.prompt, 'keydown', (event) => {\n if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {\n event.preventDefault();\n labRun('');\n }\n });\n listen(lab.modes, 'change', () => {\n labModeShow();\n if (!lab.active && !lab.shared) {\n lab.view = null;\n lab.outputs.replaceChildren();\n labCaption(labMode() === 'sweep');\n labDirty();\n }\n });\n listen(lab.clear, 'click', historyClear);\n listen(lab.share, 'click', labCopyLink);\n listen(lab.ownCopy, 'click', () => copyText(lab.own.textContent, lab.ownCopy));\n listen(window, 'resize', labDirty);\n listen(window, 'hashchange', () => {\n if (SHARE_ADDRESS.test(location.hash)) labShared();\n });\n if (typeof ResizeObserver === 'function') {\n const watch = new ResizeObserver(() => labDirty());\n watch.observe(lab.canvas);\n lab.off.push(() => watch.disconnect());\n }\n if (!lab.options.share) lab.share.hidden = true;\n labCaption(false);\n labModeShow();\n historyShow();\n labShared();\n labInfo();\n labPaint();\n return true;\n }\n function unmount() {\n if (!lab) return false;\n const gone = lab;\n lab = null;\n if (gone.active) gone.active.abort();\n clearInterval(gone.timer);\n clearTimeout(gone.poll);\n if (gone.frame) cancelAnimationFrame(gone.frame);\n for (const off of gone.off) off();\n gone.host.replaceChildren();\n gone.host.classList.remove('aien-speed');\n return true;\n }\n window.AienSpeed = Object.freeze({ mount, unmount });\n})();\n"
88
89fn sp_prelude to void
90for b ulong len sp0
91raw get sp0 b
92end
93end
94
95fn sp_helpers to void
96for b ulong len sp1
97raw get sp1 b
98end
99end
100
101fn sp_build to void
102for b ulong len sp2
103raw get sp2 b
104end
105end
106
107fn sp_format to void
108for b ulong len sp3
109raw get sp3 b
110end
111end
112
113fn sp_say to void
114for b ulong len sp4
115raw get sp4 b
116end
117end
118
119fn sp_modes to void
120for b ulong len sp5
121raw get sp5 b
122end
123end
124
125fn sp_info to void
126for b ulong len sp6
127raw get sp6 b
128end
129end
130
131fn sp_lanes to void
132for b ulong len sp7
133raw get sp7 b
134end
135end
136
137fn sp_rows to void
138for b ulong len sp8
139raw get sp8 b
140end
141end
142
143fn sp_history to void
144for b ulong len sp9
145raw get sp9 b
146end
147end
148
149fn sp_share to void
150for b ulong len sp10
151raw get sp10 b
152end
153end
154
155fn sp_event to void
156for b ulong len sp11
157raw get sp11 b
158end
159end
160
161fn sp_run to void
162for b ulong len sp12
163raw get sp12 b
164end
165end
166
167fn sp_paint to void
168for b ulong len sp13
169raw get sp13 b
170end
171end
172
173fn sp_axes to void
174for b ulong len sp14
175raw get sp14 b
176end
177end
178
179fn sp_draw to void
180for b ulong len sp15
181raw get sp15 b
182end
183end
184
185fn sp_ratedraw to void
186for b ulong len sp16
187raw get sp16 b
188end
189end
190
191fn sp_sweepdraw to void
192for b ulong len sp17
193raw get sp17 b
194end
195end
196
197fn sp_mount to void
198for b ulong len sp18
199raw get sp18 b
200end
201end
202
203fn main to int
204put target 0 1
205sp_prelude
206sp_helpers
207sp_build
208sp_format
209sp_say
210sp_modes
211sp_info
212sp_lanes
213sp_rows
214sp_history
215sp_share
216sp_event
217sp_run
218sp_paint
219sp_axes
220sp_draw
221sp_ratedraw
222sp_sweepdraw
223sp_mount
224flush
225ret 0
226end