|
|
|
|
|
by vdfs
1363 days ago
|
|
The code my clarify that up, it simply calculate how much time an http request take to complete: function ping_test() {
time_request("http://ping.projects.chrisjeakle.com/ping/data.txt", "result-east");
time_request("http://ping.projects-west.chrisjeakle.com/ping/data.txt", "result-west");
}
function time_request(url, output_id) {
document.getElementById(output_id).innerText = "...";
const start_time = new Date().getTime();
fetch(url, {
mode: "no-cors",
cache: "no-cache",
}).then(async (result) => {
const elapsed_time = new Date().getTime() - start_time;
document.getElementById(output_id).innerText = elapsed_time;
});
}
|
|
Also, maybe you should run the tests in sequence instead of at the same time. I wonder if running two concurrent fetches might disadvantage the second fetch?