What would be the best way to measure network latency in React Native?
E.g.
const startTime = Date.now();
let response = await fetch(url)
const endTime = Date.now();
const totalTimeInMs = endTime - startTime;
If I place start and stop timer before/after the network call as shared above that might not give true network latency because the JS might be busy doing some other work and would come to this eventually when there is nothing in the event loop / call back queue / task.
Hence wondering if there is any better way to measure network latency?
Solution 1:
install Axios library
response.latencywill give the totalTimeInMsFull Code
Solution 2:
by using fetch, but fetch does not give us default timing attributes