1// The getTime() method returns the number of milliseconds since midnight of January 1, 1970.
2
3
4var start = new Date().getTime();
5
6for (i = 0; i < 50000; ++i) {
7// do something
8}
9
10var end = new Date().getTime();
11var time = end - start;
12alert('Execution time: ' + time);
1var start = new Date().getTime();
2
3for (i = 0; i < 50000; ++i) {
4// do something
5}
6
7var end = new Date().getTime();
8var time = end - start;
9alert('Execution time: ' + time);
1console.time("timer"); //start time with name = timer
2console.timeEnd("timer"); //end timer and log time difference