Code Timer

Time how long it takes to run a function using Date.now();

by Gary Pyne

JavaScript

var start = Date.now();
var i = 0;

myFunc();

var stop = Date.now();
document.write(stop - start + " Milliseconds");

function myFunc() {
    while (i < 100000) {
        i++;
    }
}