性能 只读特性在 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.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
性能 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

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改: