Skip to content

Instantly share code, notes, and snippets.

@yasakbulut
Created January 14, 2014 07:18
Show Gist options
  • Save yasakbulut/8414421 to your computer and use it in GitHub Desktop.
Save yasakbulut/8414421 to your computer and use it in GitHub Desktop.
Calculates the average response time (in milliseconds) for requests made to an URL containing a specified keyword, given an object containing HAR (Http ARchive) data.
function getAvgResponseTimeForURL(har, keyword){
har.log.entries.filter(function(a){return a.request.url.indexOf(keyword)!=-1}).map(function(a){ return a.time}).reduce(function(previousValue, currentValue, index, array){return previousValue + (currentValue / array.length);},0);
}
@yasakbulut
Copy link
Author

Usage:

har = {...} //Pasted HAR data
getAvgResponseTimeForURL(har, "search.json");

>> 4.43786345873465 //that is a fast-ass search 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment