Skip to content

Commit cd2f035

Browse files
committed
observe and track times for changes to console
1 parent 14e6d1b commit cd2f035

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/components/OverviewItem/stories/OverviewItemListPerformance.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const OverviewItemListPerformance = ({
6767
}: OverviewItemListPerformanceProps) => {
6868
const renderStart = new Date();
6969
const containerRef = React.useRef(null);
70+
const observerRef = React.useRef<MutationObserver | undefined>(undefined);
7071

7172
const iconNames = Object.keys(canonicalIcons);
7273

@@ -87,6 +88,23 @@ export const OverviewItemListPerformance = ({
8788
"OverviewItemListPerformance Rendering time (s)",
8889
(renderEnd.getTime() - renderStart.getTime()) / 1000
8990
);
91+
92+
if (containerRef.current) {
93+
let changeCount = 0;
94+
const changeReporter = () => {
95+
const renderChange = new Date();
96+
// eslint-disable-next-line no-console
97+
console.log(
98+
`Change ${++changeCount} after time (s)`,
99+
(renderChange.getTime() - renderEnd.getTime()) / 1000
100+
);
101+
};
102+
if (observerRef.current) {
103+
observerRef.current.disconnect();
104+
}
105+
observerRef.current = new MutationObserver(changeReporter);
106+
observerRef.current.observe(containerRef.current, { childList: true, subtree: true });
107+
}
90108
});
91109

92110
return (

0 commit comments

Comments
 (0)