Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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