Skip to main content

System Pressure Monitor

Get informed about your system compute pressure. Under the hood it utilizes the Compute Pressure API with source "CPU".

info

Available since EyesonJS v1.9.3
Works currently only in Chromium based browsers (Chrome, Edge, Opera, etc.) since version 125. See caniuse.com.

import { FeatureDetector, SystemPressureMonitor } from 'eyeson'

FeatureDetector.canMonitorSystemPressure()

const monitor = new SystemPressureMonitor({ sampleInterval })

monitor.onUpdate(state => {
console.log(`cpu pressure: ${state}`)
})

monitor.offUpdate(fn) // specific function

monitor.offUpdate() // clear all

await monitor.start()

monitor.stop() // call stop for a pause and start later again

monitor.destroy()

Pressure states

nominal

The conditions of the target device are at an acceptable level with no noticeable adverse effects on the user.

fair

Target device pressure, temperature and/or energy usage are slightly elevated, potentially resulting in reduced battery-life, as well as fans (or systems with fans) becoming active and audible. Apart from that the target device is running flawlessly and can take on additional work.

serious

Target device pressure, temperature and/or energy usage is consistently highly elevated. The system may be throttling as a countermeasure to reduce thermals.

critical

The temperature of the target device or system is significantly elevated and it requires cooling down to avoid any potential issues.

Source: https://w3c.github.io/compute-pressure/#pressure-states

Sample Interval

The sample interval is the requested sampling interval expressed in milliseconds. It defaults to 1000ms. We recommend setting it to some seconds to avoid many quick switches.

Permission

FeatureDetector.canMonitorSystemPressure() also performs a permission check.

If you're running SystemPressureMonitor inside an IFrame, make sure to add compute-pressure to the allow list.

See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy/compute-pressure for more information.

note

Eyeson IFrame API already includes the compute-pressure permission.