Skip to content

Instantly share code, notes, and snippets.

@akanshgulati
Created June 18, 2019 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akanshgulati/35b48415c65c057a2574dec0c50d6f62 to your computer and use it in GitHub Desktop.
Save akanshgulati/35b48415c65c057a2574dec0c50d6f62 to your computer and use it in GitHub Desktop.
Get average performance of server from KeyCDN performance tool
(function () {
const TTFBIndex = 8
const rows = Array.from(document.querySelector(`#perfResult`).children[1].tBodies[0].children).slice(1)
const sum = rows.reduce((acc, row) => {
var text = row.children[TTFBIndex].innerText
if (text.indexOf(`ms`) > -1) {
// if result is in seconds
acc += parseFloat(text)
} else if (text.indexOf(`s`) > -1) {
// is result is in seconds instead
acc += parseFloat(text)*1000
}
return acc
}, 0);
console.log(`Average `, sum / rows.length, " ms");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment