okami.mom/strata

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

Niko1221merge f-split-fr (owner app UI fixes, rounds 1-5) into f-split-int8820fa433

main
1.9 KiB31 linesraw
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', () => {
13  const out = withHostSensors(live, host);
14  assert.equal(out.hardware.gpus[0].temperatureC, 41);
15  assert.equal(out.hardware.gpus[0].memoryUsedGb, 0.9);
16  assert.equal(out.hardware.gpuLoad, 7);
17  assert.equal(out.hardware.powerW, 22);
18  assert.equal(out.hardware.pcieRxMbs, 3);
19  assert.equal(out.hardware.cpuLoad, 20, 'what the engine reported is kept');
20});
21
22test('what a running engine reports wins over the host sensors', () => {
23  const running = { hardware: { ...live.hardware, gpus: [{ ...none, temperatureC: 55, utilizationPct: 90 }], gpuTempC: 55, gpuLoad: 90 } };
24  const out = withHostSensors(running, host);
25  assert.equal(out.hardware.gpus[0].temperatureC, 55);
26  assert.equal(out.hardware.gpuLoad, 90);
27});
28
29test('no host monitor, no change', () => {
30  assert.equal(withHostSensors(live, null), live);
31});