How long does it take to perform a for-loop 100.000 times:
Press F12 on your keyboard to view the result in the console view.
the console.time()
method starts the timer and the console.timeEnd()
method ends the timer and writes the result in the console view.
<!DOCTYPE html> <html> <body> <script> console.time(); for (i = 0; i < 100000; i++) { // some code/* w w w. j a va 2s . com*/ } console.timeEnd(); </script> </body> </html>
The console.time()
method starts a timer in the console view.
console.time(label);
Parameter Values
Parameter | Type | Description |
---|---|---|
label | String | Optional. Use the label parameter to give the timer a name |