Created by Jerry Wang, last modified on Sep 27, 2014

<html>
<script>
 function process() {
  var arra = [];
  var count = 900000;
  for( var i = 0; i < count; i++) {
  arra[i] = i;
  }
  console.log("array length: " + arra.length);
 }
 
 var start = +new Date(a);console.time("insert array");
 process();
 var end = +new Date(a);console.timeEnd("insert array");
 console.log("time spent: " + ( end - start));
</script>
</html>
Copy the code

Within the Function Process, the implementation populates a large array. If you need to count the number of milliseconds it takes to populate a specified number of arrays, method 1 can do the difference by manually fetching timestamps at two points in time before and after the call function.

Another way to do this is to use Chrome’s console. Time, which is more accurate: