add performance calc
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user