Why does my program measure an increased speed of an asynchronous function when it is minimized, and steadily decrease in measured when the window is open?
async function fetchLiveData(event, id){
const startTime = performance.now();
const dataQuery = ' SELECT * FROM "table" WHERE id = $1 ';
const result = await client.query(dataQuery , [id]);
const endTime = performance.now();
console.log(`fetchLiveData took ${endTime - startTime} milliseconds to complete.`);
}
While the window is minimized, the measured time drops to 300ms and then stops updating the console
Then when the window is open, the measured time increases steadily, which does not reflect what is actually happening. This fetchLiveData function is on a 250ms timer, and it is executing fine
