English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
console.time()The method starts a timer that you can use to track the time spent on operations.
UsagelabelTimer names with parameters, so you can have many timers on the same page.
When you use the same name to callconsole.timeEnd()at that time, the browser will output the time elapsed since the timer started (in milliseconds).
console.time(label)
console.time(); for (let i = 0; i < 1000; i++) { // pass } console.timeEnd();Test and see‹/›
All browsers fully support the console.time() method:
Method | |||||
console.time() | Yes | Yes | Yes | Yes | Yes |
Parameter | Description |
---|---|
label | (Optional) Provide a new timer name. This will determine the timer; when calling console.timeEnd() to stop the timer and output the time to the specified console, please use the same name. |
UsagelabelParameter:
console.time("myLabel"); for (let i = 0; i < 1000; i++) { // pass } console.timeEnd("myLabel");Test and see‹/›