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에서 사용할 수 있습니다
mark
의 performance entry
는 다음 속성값을 갖습니다:
entryType
(en-US) - "mark
"로 설정됩니다.name
(en-US) - mark가 생성될 때 주어진 "name
"으로 설정됩니다.startTime
(en-US) -mark()
가 호출되었을 때의timestamp
(en-US)가 설정됩니다.duration
(en-US) - "0
"으로 설정됩니다. (duration이 없는 mark).
만약 메서드에 주어진 name
이 이미 PerformanceTiming
(en-US) 인터페이스 상에 존재한다면 SyntaxError
를 throw 합니다.
Syntax
js
performance.mark(name);
Arguments
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