Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

console.time() — start a timer

console.time() starts a named timer. Use the same label with console.timeEnd() to display the elapsed time and end the measurement.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

console.time();
console.time(label);

console.time(label) records the start time in the console object's timer table and returns undefined. An omitted label defaults to "default".

Reusing an active label does not restart its timer; it may produce a warning. console.timeLog(label) displays elapsed time without stopping. console.timeEnd(label) displays elapsed time and removes the timer, allowing label reuse.

This is a Console Standard API, not an ECMAScript-defined function. Duration formatting is implementation-defined. The example produces a fixed sum, not a fixed duration; do not compare the exact timing text.

Examples

{
  console.time("sum");
  let sum = 0;
  for (let i = 1; i <= 100; i++) {
    sum += i;
  }
  console.timeEnd("sum");
  console.log(sum);
}

Result

sum: <duration>
5050

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources