Javascript - Web development basic Series: Measuring Execution Time with console.time

Опубликовано: 29 Июль 2026
на канале: Web Development Tutorials
0

Today we'll see a simple JavaScript trick to measure the execution time of any piece of code, and you'll get to see it in action.

Code walkthrough (javascript):
‹console.time('loop duration');›
‹let total = 0;›
‹for (let i = 0; i ‹ 100000; i++) {›
‹total += i;›
‹}›
‹console.timeEnd('loop duration');›

What it looks like: Guessing whether one approach is actually faster than another 😕 → An exact millisecond measurement of real code performance ✅

Try it yourself: Try measuring the execution time of a simple loop function yourself.

#javascripttimingfunction #console.timeexample #javascriptexecutiontimemeasurement #measuringjscodeperformance #javascriptconsoletimemethod #timedebuggingjavascript #jstimingcode #javascriptexecutionspeedtest #webdev #html #coding #programming #tutorial