Files
faunosteo/scripts/browser/lib/host.mjs
T
bchanot 4439fd2420 test(tests): R4.1e browser harness and TS baselines (Chromium, Firefox, WebKit)
Playwright harness under scripts/browser: 127.0.0.1 server with the DEPLOY
CSP, export and import baselines of the TypeScript engine under a 4 GiB RSS
watchdog (not a guaranteed memory limit), O9 browser columns in
inflate.browsers.json (26 rows agree with Node in all three engines).
Results of 2026-10-18 committed; the O9 Node test no longer expects browser
columns in inflate.json.
2026-10-18 15:05:28 +02:00

28 lines
768 B
JavaScript

import { readFileSync } from 'node:fs'
import { arch, cpus, release, totalmem } from 'node:os'
/** The host facts a reader of the results needs to compare devices. */
export function memAvailableBytes() {
const info = readFileSync('/proc/meminfo', 'utf8')
const match = /^MemAvailable:\s+(\d+) kB$/m.exec(info)
return match ? Number(match[1]) * 1024 : null
}
function cpuModel() {
const info = readFileSync('/proc/cpuinfo', 'utf8')
return /^model name\s*:\s*(.+)$/m.exec(info)?.[1] ?? cpus()[0]?.model
}
export function hostFacts() {
return {
cpuModel: cpuModel(),
logicalCpus: cpus().length,
ramBytes: totalmem(),
memAvailableBytesAtStart: memAvailableBytes(),
kernel: release(),
arch: arch(),
node: process.version,
}
}