このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

Performance: clearMarks() メソッド

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2017年9月.

clearMarks() メソッドは、すべての、または特定の PerformanceMark オブジェクトを、ブラウザーのパフォーマンスタイムラインから除去します。

構文

js
clearMarks()
clearMarks(name)

引数

name 省略可

文字列で、 PerformanceMark オブジェクトの名前を表します。この引数を省略すると、 entryType が "mark" であるすべての項目が除去されます。

返値

なし (undefined)。

マーカーを除去

パフォーマンスマークをすべて、あるいは特定の項目だけを消去するには、次のように clearMarks() メソッドを使用します。

js
// マークの束を作成
performance.mark("login-started");
performance.mark("login-started");
performance.mark("login-finished");
performance.mark("form-sent");
performance.mark("video-loaded");
performance.mark("video-loaded");

performance.getEntriesByType("mark").length; // 6

// "login-started" マーク項目のみを削除
performance.clearMarks("login-started");
performance.getEntriesByType("mark").length; // 4

// すべてのマーク項目を削除
performance.clearMarks();
performance.getEntriesByType("mark").length; // 0

仕様書

Specification
User Timing
# dom-performance-clearmarks

ブラウザーの互換性

関連情報