Skip to content

Instantly share code, notes, and snippets.

@reeceatkinson
Last active November 3, 2023 22:53
Show Gist options
  • Save reeceatkinson/dcf33f5c150314cc82ea32e10d9d659c to your computer and use it in GitHub Desktop.
Save reeceatkinson/dcf33f5c150314cc82ea32e10d9d659c to your computer and use it in GitHub Desktop.
ABC_ARC-RA
function measureSpeed() {
fetch('https://fast.com/speedtest/').then(response => {
return response.text();
}).then(data => {
const match = data.match(/speed-results-primary.*?(\d+\.\d+)/);
if (match) {
const downloadSpeed = match[1];
console.log('Download speed: ' + downloadSpeed + ' Mbps');
} else {
console.log('Speed test failed.');
}
}).catch(error => {
console.log('Error: ' + error);
});
}
// Run the speed test every 5 minutes (300,000 milliseconds)
setInterval(measureSpeed, 300000);
// Initial measurement
measureSpeed();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment