PerformanceEntry.entryType - Web APIs 编辑

The entryType property returns a DOMString representing the type of performance metric such as, for example, "mark". This property is read only.

Note:

This feature is available in Web Workers.

Syntax

var type = entry.entryType;

Return value

The return value depends on the subtype of the PerformanceEntry object and affects the value of the PerformanceEntry.name property as shown by the table below.

Performance entry type names

ValueSubtypeType of name propertyDescription of name property
frame, navigationPerformanceFrameTiming, PerformanceNavigationTimingURLThe document's address.
resourcePerformanceResourceTimingURLThe resolved URL of the requested resource. This value doesn't change even if the request is redirected.
markPerformanceMarkDOMStringThe name used when the mark was created by calling performance.mark().
measurePerformanceMeasureDOMStringname used when the measure was created by calling performance.measure().
paintPerformancePaintTimingDOMString

Either 'first-paint' or 'first-contentful-paint'.

longtaskPerformanceLongTaskTimingDOMStringreports instances of long tasks

Example

The following example shows the use of the entryType property.

function run_PerformanceEntry() {

  // check for feature support before continuing
  if (performance.mark === undefined) {
    console.log("performance.mark not supported");
    return;
  }

  // Create a performance entry named "begin" via the mark() method
  performance.mark("begin");

  // Check the entryType of all the "begin" entries
  var entriesNamedBegin = performance.getEntriesByName("begin");
	for (var i=0; i < entriesNamedBegin.length; i++) {
      var typeOfEntry = entriesNamedBegin[i].entryType;
      console.log("Entry is type: " + typeOfEntry);
  }

}

Specifications

SpecificationStatusComment
Performance Timeline Level 2
The definition of 'entryType' in that specification.
Candidate Recommendation
Performance Timeline
The definition of 'entryType' in that specification.
RecommendationInitial definition.

Browser compatibility

BCD tables only load in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:122 次

字数:5433

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文