okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
8820fa433
main
1import test from 'node:test' ; 2import assert from 'node:assert/strict' ; 3import { build } from 'esbuild' ; 4 5const built = await build ({ stdin :{ contents :"export * from './src/lib/native-monitor';" , resolveDir :process . cwd () }, bundle :true , write :false , format :'esm' , platform :'node' , loader :{ '.json' :'json' } }); 6const { withHostSensors} = await import ( `data:text/javascript;base64, ${ Buffer . from ( built . outputFiles [ 0 ]. text ). toString ( 'base64' )} ` ); 7 8const none = { id :'GPU-1' , utilizationPct :null , temperatureC :null , memoryUsedGb :null , powerW :null , powerLimitW :null , pcieRxMbs :null }; 9const live = { hardware :{ gpus :[ none ], gpuLoad :NaN , vramUsedGb :NaN , vramTotalGb :11.9 , gpuTempC :NaN , powerW :NaN , powerLimitW :NaN , pcieRxMbs :NaN , cpuLoad :20 } }; 10const host = { hardware :{ gpus :[{ id :'GPU-1' , utilizationPct :7 , temperatureC :41 , memoryUsedGb :0.9 , powerW :22 , powerLimitW :250 , pcieRxMbs :3 }], gpuLoad :7 , vramUsedGb :0.9 , vramTotalGb :11.9 , gpuTempC :41 , powerW :22 , powerLimitW :250 , pcieRxMbs :3 } }; 11 12test ( 'with no model loaded the GPU temperature, load, VRAM, power and PCIe come from the host sensors' , () => { 13const out = withHostSensors ( live , host ); 14assert . equal ( out . hardware . gpus [ 0 ]. temperatureC , 41 ); 15assert . equal ( out . hardware . gpus [ 0 ]. memoryUsedGb , 0.9 ); 16assert . equal ( out . hardware . gpuLoad , 7 ); 17assert . equal ( out . hardware . powerW , 22 ); 18assert . equal ( out . hardware . pcieRxMbs , 3 ); 19assert . equal ( out . hardware . cpuLoad , 20 , 'what the engine reported is kept' ); 20}); 21 22test ( 'what a running engine reports wins over the host sensors' , () => { 23const running = { hardware :{ ...live . hardware , gpus :[{ ...none , temperatureC :55 , utilizationPct :90 }], gpuTempC :55 , gpuLoad :90 } }; 24const out = withHostSensors ( running , host ); 25assert . equal ( out . hardware . gpus [ 0 ]. temperatureC , 55 ); 26assert . equal ( out . hardware . gpuLoad , 90 ); 27}); 28 29test ( 'no host monitor, no change' , () => { 30assert . equal ( withHostSensors ( live , null ), live ); 31});