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 September 2015.

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

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
clearMarks

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Requires a vendor prefix or different name for use.
Has more compatibility info.

関連情報