performance.clearMeasures()
clearMeasures()
メソッドは、ブラウザーのパフォーマンスエントリーバッファーから名前付きメジャーを削除します。このメソッドが引数なしで呼び出された場合、エントリー種別が "measure
" のパフォーマンスエントリーがすべてパフォーマンスエントリーバッファーから削除されます。
注: この機能は Web Worker 内で利用可能です
構文
js
performance.clearMeasures();
performance.clearMeasures(name);
引数
- name 省略可
-
タイムスタンプの名前を表す
DOMString
です。 この引数を省略すると、エントリー種別が "measure
" であるすべてのパフォーマンスエントリーが削除されます。
返値
- void
- :
例
次の例は、clearMeasures()
メソッドの両方の使用方法を示しています。
js
// Create a small helper to show how many PerformanceMeasure entries there are.
function logMeasureCount() {
console.log(
"Found this many entries: " +
performance.getEntriesByType("measure").length,
);
}
// Create a bunch of measures.
performance.measure("from navigation");
performance.mark("a");
performance.measure("from mark a", "a");
performance.measure("from navigation");
performance.measure("from mark a", "a");
performance.mark("b");
performance.measure("between a and b", "a", "b");
logMeasureCount(); // "Found this many entries: 5"
// Delete just the "from navigation" PerformanceMeasure entries.
performance.clearMeasures("from navigation");
logMeasureCount(); // "Found this many entries: 3"
// Delete all of the PerformanceMeasure entries.
performance.clearMeasures();
logMeasureCount(); // "Found this many entries: 0"
仕様書
Specification |
---|
User Timing # dom-performance-clearmeasures |
ブラウザーの互換性
BCD tables only load in the browser