add performance calc

This commit is contained in:
e560248
2025-04-07 15:38:36 +02:00
parent 048120adae
commit 3a4be8d359

View File

@@ -19,6 +19,8 @@ export default function UserEffect() {
return; return;
} }
const start = performance.now(); // Start measuring performance
setLoading(true); setLoading(true);
// Using AbortController to cancel the fetch request if the component unmounts // Using AbortController to cancel the fetch request if the component unmounts
@@ -33,6 +35,9 @@ export default function UserEffect() {
return response.json(); return response.json();
}).then(data => { }).then(data => {
setUser(data); setUser(data);
const end = performance.now(); // End measuring performance
const timeTaken = end - start; // Calculate the time taken
console.log(`Fetch completed in ${Math.round(timeTaken)} milliseconds`);
setLoading(false); setLoading(false);
}).catch(error => { }).catch(error => {
console.error("There was a problem with the fetch operation:", error); console.error("There was a problem with the fetch operation:", error);