English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML DOM console.time() method

 JavaScript Console Object

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).

Syntax:

console.time(label)
console.time();
for (let i = 0; i < 1000; i++) {
// pass
}
console.timeEnd();
Test and see‹/›

Browser Compatibility

All browsers fully support the console.time() method:

Method
console.time()YesYesYesYesYes

Parameter Value

ParameterDescription
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.

More Examples

UsagelabelParameter:

console.time("myLabel");
for (let i = 0; i < 1000; i++) {
// pass
}
console.timeEnd("myLabel");
Test and see‹/›

 JavaScript Console Object