PressureRecord: time property
Khả dụng hạn chế
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.
Thuộc tính chỉ đọc time trả về dấu thời gian được ghi lại cho một PressureRecord. Nó tương ứng với thời điểm dữ liệu được lấy từ hệ thống so với thời gian gốc của đối tượng toàn cục trong đó PressureObserver tạo thông báo.
Giá trị
Một DOMHighResTimeStamp đại diện cho dấu thời gian khi PressureRecord được tạo.
Ví dụ
>Sử dụng thuộc tính time
Trong ví dụ sau, chúng ta ghi lại giá trị của thuộc tính time trong callback của pressure observer.
function callback(records) {
const lastRecord = records[records.length - 1];
console.log(`Current pressure ${lastRecord.state}`);
console.log(`Current pressure observed at ${lastRecord.time}`);
}
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
| Thông số kỹ thuật |
|---|
| Compute Pressure Level 1> # the-time-attribute> |