in web/src/js/gcping.js [83:121]
async function pingAllRegions(iter) {
const regionsArr = Object.values(regions);
for (let i = 0; i < iter; i++) {
for (const region of regionsArr) {
// Takes care of the stopped button
if (pingTestStatus === PING_TEST_STOPPED_STATUS) {
break;
}
const latency = await pingSingleRegion(region.key);
// add the latency to the array of latencies
// from where we can compute the median and populate the table
regions[region.key]["latencies"].push(latency);
regions[region.key]["median"] = getMedian(
regions[region.key]["latencies"],
);
// update fastest region
if (
fastestRegion === null ||
regions[region.key]["median"] < regions[fastestRegion]["median"]
) {
fastestRegion = region.key;
}
addResult(region.key);
updateList();
}
// start displaying the fastest region after at least 1 iteration is over.
// subsequent calls to this won't change anything
displayFastest(true);
}
// when all the region latencies have been fetched, let's update our status flag
updatePingTestState(PING_TEST_STOPPED_STATUS);
}