okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221merge f-split-ui2 baeb4533b (approved UI designs, context fix, workspace default with rename, autotune progress) into f-split-intc5755ed83

main
1.5 KiB24 linesraw
1/** Item 7: the tuner's stage names map onto the five steps shown, and the speeds it reports become the live readout. */
2import test from 'node:test';
3import assert from 'node:assert/strict';
4import { readFile } from 'node:fs/promises';
5import { transform } from 'esbuild';
6
7const { code } = await transform(await readFile(new URL('../src/lib/tune-phase.ts', import.meta.url), 'utf8'), { loader: 'ts', format: 'esm' });
8const { tunePhase, tuneSpeeds } = await import(`data:text/javascript;base64,${Buffer.from(code).toString('base64')}`);
9
10test('every stage the tuner reports lands on one of the five steps, in order', () => {
11  assert.deepEqual(['start', 'waiting', undefined, null].map(tunePhase), [0, 0, 0, 0], 'checking the PC, also while it waits for a quiet PC');
12  assert.equal(tunePhase('base'), 1);
13  assert.deepEqual(['plan', 'rounds', 'drift', 'per_request'].map(tunePhase), [2, 2, 2, 2]);
14  assert.equal(tunePhase('confirm'), 3);
15  assert.equal(tunePhase('done'), 4);
16  assert.equal(tunePhase('something new'), 0, 'an unknown stage never breaks the page');
17});
18
19test('the speeds are what the tuner measured, base first, and nothing invented', () => {
20  assert.deepEqual(tuneSpeeds(undefined), []);
21  assert.deepEqual(tuneSpeeds({ stage: 'rounds' }), []);
22  const speeds = tuneSpeeds({ stage: 'rounds', speeds: [{ label: 'base', tok_s: 41.2 }, { label: 'More experts in memory', tok_s: 46.8 }, { label: 'bad', tok_s: 0 }, { label: 'worse', tok_s: 'x' }] });
23  assert.deepEqual(speeds, [{ label: 'base', tok_s: 41.2 }, { label: 'More experts in memory', tok_s: 46.8 }]);
24});