Created
June 18, 2019 05:56
-
-
Save akanshgulati/35b48415c65c057a2574dec0c50d6f62 to your computer and use it in GitHub Desktop.
Get average performance of server from KeyCDN performance tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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