Last active
June 9, 2019 19:21
-
-
Save akanshgulati/75a031c33878f97c0008b781184506c3 to your computer and use it in GitHub Desktop.
Script to extract perf results from KeyCDN
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
// Calculates the average of TTFB from various locations of the | |
// KeyCDN server using its performance tool - https://tools.keycdn.com/performance | |
// Paste this script in the console after getting the performance test of a url | |
(function () { | |
const TTFBIndex = 8 | |
// Get all the rows of the performance table and remove the first heading row from it; | |
const rows = Array.from(document.querySelector(`#perfResult`).children[1].tBodies[0].children).slice(1); | |
// calculating sum of the values | |
const sum = rows.reduce((acc, row) => { | |
var text = row.children[TTFBIndex].innerText; | |
if (text.indexOf(`ms`) > -1) { | |
acc += parseFloat(text); | |
} else if (text.indexOf(`s`) > -1) { | |
acc += parseFloat(text); | |
} | |
return acc | |
}, 0) | |
console.log(`Average `, sum / rows.length); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment