Measures the performance of an asynchronous function by timing its execution.
The return type of the asynchronous function.
A label to identify the measurement in the console log.
The asynchronous function to be measured.
A promise that resolves to the result of the asynchronous function.
async function fetchData() { // Simulate an API call return new Promise((resolve) => setTimeout(() => resolve("data"), 1000));}const result = await measurePerformance("Fetch Data", fetchData);console.log(result); // Outputs: "data" Copy
async function fetchData() { // Simulate an API call return new Promise((resolve) => setTimeout(() => resolve("data"), 1000));}const result = await measurePerformance("Fetch Data", fetchData);console.log(result); // Outputs: "data"
Measures the performance of an asynchronous function by timing its execution.