The Console.time and Console.timeend methods allow developers to use in arbitrary code, and the result shown is the intermediate duration, in milliseconds. Because JavaScript performance is more and more important, it is useful for programmers to understand basic benchmarking techniques. One of the simplest benchmark tools is the console.time and console.timeend combination.
Console.time starts a timer. Instead, Console.timeend stops the timer and writes out the elapsed time:
Start Timer (Name=testforeach)
console.time (' Testforeach ');
// (... Perform certain tests, such as a ForEach loop
, etc.//end timer, get run time
console.timeend (' Testforeach ');
Testforeach:13636.634ms (direct display at console, run time)
The first parameter passed in is the name of the timer to differentiate/respond to situations where multiple timers are required at the same time. Call Console.timeend immediately prints out the run time, in MS (MS).
console.time/timeend provides a manual speed test method! In addition, in the JS field there are many advanced performance/benchmarking technology and tools.
Translator: Anchor Http://blog.csdn.net/renfufei
Translation time: April 30, 2016
Original Date: April 4, 2016
Original link: https://davidwalsh.name/console-time