function callback(records) {
const lastRecord = records[records.length - 1];
console.log(`Current pressure source: ${lastRecord.source}`);
}
try {
const observer = new PressureObserver(callback);
await observer.observe("cpu", {
sampleInterval: 1000, // 1000ms
});
} catch (error) {
// report error setting up the observer
}PressureRecord: source property / notebook
PressureRecord: source property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.