Skip to content

Commit b95162d

Browse files
authored
Add perf.mark(), console.timeStamp() (#65)
1 parent c80f93a commit b95162d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

photo-gallery/gallery.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,19 @@ addEventListener('input', e => {
370370
}
371371
},
372372
});
373+
374+
performance.mark("Filter Applied", {
375+
detail: {
376+
devtools: {
377+
dataType: "marker",
378+
color: "secondary",
379+
properties: [
380+
['Filter Value', filter.value]
381+
],
382+
tooltipText: "Filter Applied"
383+
}
384+
}
385+
});
373386
}
374387
});
375388

@@ -411,6 +424,15 @@ addEventListener('keydown', e => {
411424
});
412425

413426
function loadPhoto(fileName) {
427+
// Take a start timestamp
428+
const start = performance.now();
429+
// Measure duration from start to now
430+
console.timeStamp("measure 1", start, undefined, "My Track", "My Group", "primary-light");
431+
// Take an end timestamp
432+
const end = performance.now();
433+
// Measure duration from start to end
434+
console.timeStamp("measure 2", start, end, "My Track", "My Group", "secondary-dark");
435+
414436
const loadStartTime = performance.now();
415437
const perfMeasureDescription = `Loading photo: ${fileName}`;
416438

@@ -435,6 +457,19 @@ function loadPhoto(fileName) {
435457
},
436458
});
437459

460+
performance.mark("Photo Loaded", {
461+
detail: {
462+
devtools: {
463+
dataType: "marker",
464+
color: "secondary",
465+
properties: [
466+
['Photo', fileName]
467+
],
468+
tooltipText: "Photo Loaded"
469+
}
470+
}
471+
});
472+
438473
resolve(imageEl);
439474
}, { once: true });
440475
});

0 commit comments

Comments
 (0)