performance.mark()

mark() 메소드는 브라우저의 performance entry buffer에 주어진 이름으로 timestamp (en-US)를 생성합니다. timestamp가 정의된 응용프로그램은 Performance (en-US) 인터페이스의 getEntries*() 메소드들을 통해 불러올 수 있습니다. (getEntries() (en-US), getEntriesByName() (en-US), getEntriesByType() (en-US)).

참고: 이 기능은 Web Worker에서 사용할 수 있습니다.

markperformance entry는 다음 속성값을 갖습니다:

만약 메서드에 주어진 name이 이미 PerformanceTiming (en-US) 인터페이스 상에 존재한다면 SyntaxError를 throw 합니다.

Syntax

js
performance.mark(name);

Arguments

name

mark의 이름을 나타내는 DOMString.

Return value

void

Example

다음 예시는 mark()를 사용하여 PerformanceMark (en-US)를 생성하고 불러오는 방법을 보여줍니다.

js
// Create a bunch of marks.
performance.mark("squirrel");
performance.mark("squirrel");
performance.mark("monkey");
performance.mark("monkey");
performance.mark("dog");
performance.mark("dog");

// Get all of the PerformanceMark entries.
const allEntries = performance.getEntriesByType("mark");
console.log(allEntries.length);
// 6

// Get all of the "monkey" PerformanceMark entries.
const monkeyEntries = performance.getEntriesByName("monkey");
console.log(monkeyEntries.length);
// 2

// Clear out all of the marks.
performance.clearMarks();

명세서

Specification
User Timing
# dom-performance-mark

브라우저 호환성

BCD tables only load in the browser