JavaScript
//Benchmark - TIMER
var timer = {
startedAt: null,
stoppedAt: null,
start: function () {
this.stoppedAt = null;
this.startedAt = new Date();
},
stop: function () {
this.stoppedAt = new Date();
},
getTime: function () {
if (!this.stoppedAt) this.stop();
return this.stoppedAt.getTime() - this.startedAt.getTime();
}
};
timer.start();
var array = [[1,2,3,4,5,65,7,8],[1,2,3,4,5,65,7,8],[1,2,3,4,5,65,7,8],[1,2,3,4,5,65,7,8],[1,2,3,4,5,65,7,8],[1,2,3,4,5,65,7,8],[1,2,3,4,5,65,7,8],[1,2,3,4,5,65,7,8],[1,2,3,4,5,65,7,8],[1,2,3,4,5,65,7,8],[1,2,3,4,5,65,7,8]];
for (i = 0; i < 10 i++) {
if(array[4][6] == 3){
var a = "a";
}
}
$('#ans').append('<p>Naive: ' + timer.getTime() + 'ms</p>');
console.log(timer.getTime());