性能
只读特性在
WorkerGlobalScope
interface returns a
性能
object to be used on the worker.
并非所有
性能
properties and methods are available to Web workers.
此特性是 只读 .
var perfObj = self.performance;
A
性能
对象。
If you called
console.log(performance);
inside a worker (which would basically be the equivalent of
self.console.log(self.performance);
, as these are being called on the worker scope, which can be referenced with
WorkerGlobalScope.self
), you will get a
WorkerPerformance
object written to the console — something like the following:
WorkerPerformance {now: function}
__proto__: WorkerPerformance
constructor: function WorkerPerformance() { [native code] }
now: function now() { [native code] }
__proto__: Object
You could use this performance object to return performance data, as you might do with a normal
性能
对象。
注意
: Firefox has a bug with using
console.log
inside shared/service workers (see
bug 1058644
), which may return strange results, but this should be fixed soon.
| 规范 | 状态 | 注释 |
|---|---|---|
|
High Resolution Time Level 2
The definition of 'performance' in that specification. |
推荐 | Defines WorkerGlobalScope.performance. |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
性能
|
Chrome Yes | Edge ≤79 | Firefox 34 | IE ? | Opera ? | Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android 34 | Opera Android ? | Safari iOS ? | Samsung Internet Android Yes |
完整支持
兼容性未知