The Compute Pressure API is currently available in Chrome Canary and Edge Canary behind a flag.
- Rebase to latest HEAD and compile the chromium project.
- Launch Chrome with the command line flag --enable-features=ComputePressure.
- Navigate to
about://flags
and enableExperimental Web Platform features
. - Navigate to the demo page, https://w3c.github.io/compute-pressure/demo/.
- Play with the demo.
- Download a version of Chrome with ComputePressure implemented (Chrome Canary) (Edge Canary).
- Find your Canary browser in the menu.
- Click right and select "properties".
- Add to the command line flags --enable-features=ComputePressure. (after the last ")
- Start your browser.
- Navigate to
about://flags
and enableExperimental Web Platform features
. - Navigate to the demo page, https://w3c.github.io/compute-pressure/demo/.
- Play with the demo.
// Observer Callback.functionpressureObserverCallback(updates){console.log("cpu pressure state = "+updates[0].state);console.log("timestamp = "+updates[0].time);}// Create observer with 1000ms sample interval.observer=newPressureObserver(pressureObserverCallback);// Start observer.awaitobserver.observe("cpu",{sampleInterval: 1_000});
You should see, everytime the state changes, the following:
cpu pressure state = nominal timestamp = 1671114838027.834 cpu pressure state = serious timestamp = 1671114914289.584 cpu pressure state = critical timestamp = 1671114926328.48
Stopping observer:
// Stop observer. observer.unobserve('cpu');
Other API calls and examples can be found in the specification.