PerformanceEntry
object encapsulates a single performance metric that is part of the
performance timeline
。
performance entry
can be directly created by making a performance
mark
or
measure
(for example by calling the
mark()
method) at an explicit point in an application. Performance entries are also created in indirect ways such as loading a resource (such as an image).
PerformanceEntry
instances will always be one of the following subtypes:
PerformanceMark
PerformanceMeasure
PerformanceFrameTiming
PerformanceNavigationTiming
PerformanceResourceTiming
PerformancePaintTiming
PerformanceEntry.name
只读
PerformanceEntry.entryType
property. The value of both depends on the subtype. See property page for valid values.
PerformanceEntry.entryType
只读
DOMString
representing the type of performance metric such as, for example, "
mark
". See property page for valid values.
PerformanceEntry.startTime
只读
DOMHighResTimeStamp
representing the starting time for the performance metric.
PerformanceEntry.duration
只读
DOMHighResTimeStamp
representing the time value of the duration of the performance event.
PerformanceEntry.toJSON()
PerformanceEntry
对象。
The following example checks all
PerformanceEntry
properties to see if the browser supports them and if so, write their values to the console.
function print_PerformanceEntries() {
// Use getEntries() to get a list of all performance entries
var p = performance.getEntries();
for (var i=0; i < p.length; i++) {
console.log("PerformanceEntry[" + i + "]");
print_PerformanceEntry(p[i]);
}
}
function print_PerformanceEntry(perfEntry) {
var properties = ["name",
"entryType",
"startTime",
"duration"];
for (var i=0; i < properties.length; i++) {
// Check each property
var supported = properties[i] in perfEntry;
if (supported) {
var value = perfEntry[properties[i]];
console.log("... " + properties[i] + " = " + value);
} else {
console.log("... " + properties[i] + " is NOT supported");
}
}
}
| 规范 | 状态 | 注释 |
|---|---|---|
| Resource Timing Level 3 | 编者草案 | |
| Resource Timing Level 2 | 工作草案 | |
| Resource Timing Level 1 | 候选推荐 |
添加
PerformanceResourceTiming
interface and the
resource
value for
entryType
.
|
| Navigation Timing Level 2 | 工作草案 | |
| 导航计时 | 推荐 |
添加
PerformanceNavigationTiming
interface and the
navigation
value for
entryType
.
|
| User Timing Level 2 | 工作草案 | |
| User Timing | 推荐 |
添加
PerformanceMark
and
PerformanceMeasure
interfaces as well as the
mark
and
measure
values for
entryType
.
|
| Frame Timing | 草案 |
添加
PerformanceFrameTiming
interface and the
frame
value for
entryType
.
|
|
Performance Timeline Level 2
The definition of 'PerformanceEntry' in that specification. |
候选推荐 |
添加
toJSON()
serializer method.
|
|
性能时间线
The definition of 'PerformanceEntry' in that specification. |
推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
PerformanceEntry
|
Chrome
46
|
Edge 12 | Firefox Yes | IE Yes | Opera 33 | Safari 11 |
WebView Android
46
|
Chrome Android
46
|
Firefox Android 25 | Opera Android 33 | Safari iOS 11 |
Samsung Internet Android
5.0
|
duration
|
Chrome Yes | Edge 12 | Firefox Yes | IE Yes | Opera Yes | Safari 11 | WebView Android Yes | Chrome Android Yes | Firefox Android 25 | Opera Android Yes | Safari iOS 11 | Samsung Internet Android Yes |
entryType
|
Chrome Yes | Edge 12 | Firefox Yes | IE Yes | Opera Yes | Safari 11 | WebView Android Yes | Chrome Android Yes | Firefox Android 25 | Opera Android Yes | Safari iOS 11 | Samsung Internet Android Yes |
名称
|
Chrome Yes | Edge 12 | Firefox Yes | IE Yes | Opera Yes | Safari 11 | WebView Android Yes | Chrome Android Yes | Firefox Android 25 | Opera Android Yes | Safari iOS 11 | Samsung Internet Android Yes |
startTime
|
Chrome Yes | Edge 12 | Firefox Yes | IE Yes | Opera Yes | Safari 11 | WebView Android Yes | Chrome Android Yes | Firefox Android 25 | Opera Android Yes | Safari iOS 11 | Samsung Internet Android Yes |
toJSON
|
Chrome Yes | Edge 16 | Firefox Yes | IE 不支持 No | Opera Yes | Safari 11 | WebView Android Yes | Chrome Android Yes | Firefox Android 25 | Opera Android Yes | Safari iOS 11 | Samsung Internet Android Yes |
| Available in workers | Chrome 62 | Edge ≤79 | Firefox 60 | IE ? | Opera 49 | Safari ? | WebView Android 62 | Chrome Android 62 | Firefox Android 60 | Opera Android 46 | Safari iOS ? | Samsung Internet Android 8.0 |
完整支持
不支持
兼容性未知
要求使用供应商前缀或不同名称。
PerformanceEntry