console.time()
Starts a named timer for measuring how long an operation takes.
Syntax
console.time(label)
Returns
undefined — Returns `undefined`.
Examples
console.time("loop");
for (let i = 0; i < 1e6; i++) {}
console.timeEnd("loop");
Output
loop: 2.51ms
console.time();
console.timeEnd();
Output
default: 0.01ms
Notes
- The label defaults to `"default"` when omitted.
- Stop the timer and print elapsed time with `console.timeEnd()` using
the same label.
- Up to 10,000 concurrent timers are supported in browsers.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 2.0 |
| firefox | 10 |
| safari | 4 |
| edge | 12 |
| node | 0.10 |