Speed Test
by Emily Humphrey
JavaScript
var towns = ["Hyde Park", "Poughkeepsie", "Rhinebeck", "Rhinecliff", "Red Hook"];
var bam = function(listOfParams){
}
// I don't feel like finishing, but you get the jist of it, right?
var townSpeedTest = new()
SpeedTest.prototype = {
startTest: function(){
var startTime, endTime, sumTimes = 0;
for(var i = 0, x = this.repetitions; i < x; i++){
startTime = +new Date();
this.testFunc(this.testparams);
endTime = +new Date();
sumTimes += startTime - endTime;
}
this.average = sumTimes / this.repetitions;
alert("Average execution across "+this.repetitions+": "this.average);
}
}
function SpeedTest(testFunc, testParam, repetitions){
this.testFunc = testFunc;
this.testParam = testParam;
this.repetitions = repetitions || 10000;
this.average = 0;
this.startTest();
}
var hellow = new SpeedTest();