Easy Tutorial
❮ Prop Style Paddingright Prop Colgroup Span ❯

HTML DOM console.time() Method

Console Object

Example

Time taken to execute 100,000 times:


Definition and Usage

The console.time() method is used as the starting point of a timer.

It is typically used to measure the duration of program execution.

The console.timeEnd() method is used as the ending point of the timer and displays the elapsed time in the console.

If a page requires multiple timers, you can add a label parameter to set them.

Note: The console needs to be visible during testing (open the console by pressing F12 in the browser).


Syntax

console.time(label)

Browser Support

The numbers in the table specify the first browser version that fully supports the method.

Method
console.time() Yes 11 10 4 Yes

Parameter Values

Parameter Type Description
label String Optional. Used to label the timer.
tablecolumns Array Optional. An array of table header names.

More Examples

Example

Using a label parameter:

Example

Testing which code executes faster

Console Object

❮ Prop Style Paddingright Prop Colgroup Span ❯