The getEntriesByType()
method returns a list of PerformanceEntry
objects for a given type. The list's members (entries) can be created by making performance marks or measures (for example by calling the mark()
method) at explicit points in time.
A list of PerformanceEntry
objects that have the specified type
. The items will be in chronological order based on the entries' startTime
. If no objects have the specified type
, or no argument is provided, an empty list is returned.
function usePerformanceEntryMethods() {
log("PerformanceEntry tests ...");
if (performance.mark === undefined) {
log("... performance.mark Not supported");
return;
}
performance.mark("Begin");
doWork(50000);
performance.mark("End");
performance.mark("Begin");
doWork(100000);
performance.mark("End");
doWork(200000);
performance.mark("End");
var p = performance.getEntries();
for (var i=0; i < p.length; i++) {
log("Entry[" + i + "]");
checkPerformanceEntry(p[i]);
}
p = performance.getEntries({name : "Begin", entryType: "mark"});
for (var i=0; i < p.length; i++) {
log("Begin[" + i + "]");
checkPerformanceEntry(p[i]);
}
p = performance.getEntriesByType("mark");
for (var i=0; i < p.length; i++) {
log ("Mark only entry[" + i + "]: name = " + p[i].name +
"; startTime = " + p[i].startTime +
"; duration = " + p[i].duration);
}
p = performance.getEntriesByName("Begin", "mark");
for (var i=0; i < p.length; i++) {
log ("Mark and Begin entry[" + i + "]: name = " + p[i].name +
"; startTime = " + p[i].startTime +
"; duration = " + p[i].duration);
}
}