Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. PerformanceMark
  4. PerformanceMark()

PerformanceMark: PerformanceMark() constructor

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨May 2022⁩.

Note: This feature is available inWeb Workers.

ThePerformanceMark() constructor creates atimestamp with the given name.

Unlikeperformance.mark(), performance marks created by the constructor aren't added to the browser's performance timeline. This means that calls to thePerformance interface'sgetEntries*() methods (getEntries(),getEntriesByName() orgetEntriesByType()) won't show entries for these marks.

Syntax

js
new PerformanceMark(name)new PerformanceMark(name, markOptions)

Parameters

name

A string representing the name of the mark.

markOptionsOptional

An object for specifying a timestamp and additional metadata for the mark.

detailOptional

Arbitrary metadata to include in the mark. Defaults tonull.

devtoolsOptionalExperimental

Some browsers have use a structureddevtools object within thedetail object as part of an Extensibility API that surfaces these in custom tracks in performance traces. See theChrome's Extensibility API documentation for more information.

dataTypeExperimental

A string which must be set tomarker. Identifies as a marker.

colorOptionalExperimental

Defaults to"primary". Must be one of"primary","primary-light","primary-dark","secondary","secondary-light","secondary-dark","tertiary","tertiary-light","tertiary-dark","error".

propertiesOptionalExperimental

Array of key-value pairs. Values can be any JSON-compatible type.

tooltipTextOptionalExperimental

Short description for tooltip.

startTimeOptional

DOMHighResTimeStamp to use as the mark time. Defaults toperformance.now().

Return value

APerformanceMark object.

Exceptions

Examples

Creating named markers

The following example shows howPerformanceMark entries are constructed and then aren't part of the browser's performance timeline.

js
new PerformanceMark("squirrel");new PerformanceMark("monkey");new PerformanceMark("dog");const allEntries = performance.getEntriesByType("mark");console.log(allEntries.length);// 0

DevTools Extensibility API

For browsers that support theExtensibility API you can use thedetail parameter to provide more details in adevtools object that will be used to display this in performance profiles:

js
// Marker indicating when the processed image was uploadedperformance.mark("Image Upload", {  detail: {    devtools: {      dataType: "marker",      color: "secondary",      properties: [        ["Image Size", "2.5MB"],        ["Upload Destination", "Cloud Storage"],      ],      tooltipText: "Processed image uploaded",    },  },});

Specifications

Specification
User Timing
# dom-performancemark-constructor

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp