A quick and easy way to measure the time it takes code to run is by using console.time
in conjunction with console.timeEnd
.
All you need to do is surround the code or function call you desire to evaluate with console.time
and console.timeEnd
respectively...
Pranjal Jately 👨🏽💻@pjately💡 #JavaScript tip: console.time & console.timeEnd ⏲
I'm no performance expert, but TIL a quick and easy way to measure the time it takes code to run ⬇
#100DaysOfCode #webdev #CodeNewbie #LearnInPublic #React16:37 PM - 03 Jul 2020
console.time(<label>)
starts a timer with a given (unique) label and console.timeEnd(<label>)
stops the timer with the corresponding label (the labels must match for this to work).
Once stopped, the elapsed time is automatically displayed in the console 🤯
Drop a comment if you've ever used this technique to measure the performance of your code.
Have a good one.
Top comments (0)