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;
}
const start = performance.now(); // Start measuring performance
setLoading(true);
// Using AbortController to cancel the fetch request if the component unmounts
@@ -33,6 +35,9 @@ export default function UserEffect() {
return response.json();
}).then(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);
}).catch(error => {
console.error("There was a problem with the fetch operation:", error);