PressureRecord
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Note: This feature is available in Web Workers, except for Service Workers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Giao diện PressureRecord là một phần của Compute Pressure API và mô tả xu hướng áp lực của một nguồn tại một thời điểm chuyển tiếp cụ thể.
Thuộc tính phiên bản
PressureRecord.sourceRead only Experimental-
Một chuỗi cho biết nguồn gốc mà từ đó bản ghi được gửi đến.
PressureRecord.stateRead only Experimental-
Một chuỗi cho biết trạng thái áp lực được ghi lại.
PressureRecord.timeRead only Experimental-
Một
DOMHighResTimeStampcho biết dấu thời gian của bản ghi.
Phương thức phiên bản
PressureRecord.toJSON()Experimental-
Trả về biểu diễn JSON của đối tượng
PressureRecord.
Ví dụ
>Sử dụng đối tượng PressureRecord
Trong ví dụ sau, chúng ta ghi lại các thuộc tính của đối tượng PressureRecord trong callback của pressure observer.
function callback(records) {
const lastRecord = records[records.length - 1];
console.log(`Current pressure is ${lastRecord.state}`);
console.log(`Current pressure observed at ${lastRecord.time}`);
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
}
Thông số kỹ thuật
| Specification |
|---|
| Compute Pressure Level 1> # the-pressurerecord-interface> |