okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
c5755ed83
main
1import type { TuneProgress } from './native-tune' ; 2 3/** 4* Which of the five steps the tuner is in, from the stage its status file names (strata_control/autotune.py): 5* start and waiting are the PC check, base the first measurement, plan / rounds / drift / per_request the settings tried, 6* confirm the repeat test, and done the last moment before the result is saved and shown. 7*/ 8export function tunePhase ( stage :string | undefined | null ) :number { 9switch ( stage ) { 10case 'base' :return 1 ; 11case 'plan' :case 'rounds' :case 'drift' :case 'per_request' :return 2 ; 12case 'confirm' :return 3 ; 13case 'done' :return 4 ; 14default :return 0 ; 15} 16} 17 18/** Every measurement so far: "base" first, then each setting tried, as decode tokens per second. */ 19export function tuneSpeeds ( progress :TuneProgress | undefined | null ) :{ label :string ; tok_s :number }[] { 20const list = ( progress as ( TuneProgress & { speeds ?:{ label ?:unknown ; tok_s ?:unknown }[] }) | undefined | null )?. speeds ; 21if ( ! Array . isArray ( list )) return []; 22return list . filter ( x => typeof x ?. tok_s === 'number' && Number . isFinite ( x . tok_s ) && x . tok_s > 0 ). map ( x => ({ label :String ( x . label ?? '' ), tok_s :x . tok_s as number })); 23}