PerformanceEntry.duration
duration
プロパティは、パフォーマンスエントリ
の期間であるタイムスタンプ
を返します。
注: この機能は Web Worker 内で利用可能です
このプロパティによって返される値は、パフォーマンスエントリのタイプ
によって異なります。
- "
frame
" - 連続する 2 つのフレームのstartTime
間の差を示すタイムスタンプ
を返します - "
mark
" - "0
" を返します (マークには長さがありません) - "
measure
" - メジャーの期間であるタイムスタンプ
を返します - "
navigation
" - それぞれPerformanceNavigationTiming.loadEventEnd
とPerformanceEntry.startTime
のプロパティの差であるタイムスタンプ
を返します - "
resource
" - リソースのresponseEnd
(en-US)タイムスタンプ
とそのstartTime
タイムスタンプ
の差を返します
このプロパティは 読取専用 です。
構文
entry.duration;
返値
パフォーマンスエントリ
の長さを表す DOMHighResTimeStamp
。期間の概念が特定のパフォーマンスメトリックに適用されない場合、ブラウザーは期間 0 を返すように選択することがあります。
メモ: パフォーマンスエントリが "resource
" の entryType
を持つ場合 (つまり、エントリが PerformanceResourceTiming
オブジェクトである場合)、このプロパティは PerformanceEntry.responseEnd
(en-US) と PerformanceEntry.startTime
の差のタイムスタンプ
を返します。
例
次の例は、duration
プロパティの使用方法を示しています。
function run_PerformanceEntry() {
log("PerformanceEntry support ...");
if (performance.mark === undefined) {
log("... performance.mark Not supported");
return;
}
// Create some performance entries via the mark() method
performance.mark("Begin");
do_work(50000);
performance.mark("End");
// Use getEntries() to iterate through the each entry
var p = performance.getEntries();
for (var i=0; i < p.length; i++) {
log("Entry[" + i + "]");
check_PerformanceEntry(p[i]);
}
}
function check_PerformanceEntry(obj) {
var properties = ["name", "entryType", "startTime", "duration"];
var methods = ["toJSON"];
for (var i=0; i < properties.length; i++) {
// check each property
var supported = properties[i] in obj;
if (supported)
log("..." + properties[i] + " = " + obj[properties[i]]);
else
log("..." + properties[i] + " = Not supported");
}
for (var i=0; i < methods.length; i++) {
// check each method
var supported = typeof obj[methods[i]] == "function";
if (supported) {
var js = obj[methods[i]]();
log("..." + methods[i] + "() = " + JSON.stringify(js));
} else {
log("..." + methods[i] + " = Not supported");
}
}
}
仕様書
Specification |
---|
Performance Timeline # dom-performanceentry-duration |
ブラウザーの互換性
BCD tables only load in the browser