const loginMeasure = performance.measure(
"login-duration",
"login-started",
"login-finished",
);
console.log(loginMeasure.duration);Performance: measure() method / notebook
Performance: measure() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
performance.measure("login-click", {
start: myClickEvent.timeStamp,
end: myMarker.startTime,
});performance.measure("login-click", {
detail: { htmlElement: myElement.id },
start: myClickEvent.timeStamp,
end: myMarker.startTime,
});const imageProcessingTimeStart = performance.now();
// ... later in your code
performance.measure("Image Processing Complete", {
start: imageProcessingTimeStart,
end: performance.now(),
detail: {
// This data appears in the "Summary"
extraInfo: {
imageId: "xyz-123",
source: "cache",
checkUrl: "https://example.com/check/xyz-123",
},
// The devtools object controls the track visualization
devtools: {
dataType: "track-entry",
track: "Image Processing Tasks",
trackGroup: "My Tracks",
color: "tertiary-dark",
properties: [
["Filter Type", "Gaussian Blur"],
// Values can be objects, arrays, or other types
["Resize Dimensions", { w: 500, h: 300 }],
// String values that are URLs get linkified
["Image URL", "https://example.com/img.png"],
],
tooltipText: "Image processed successfully",
},
},
});