console.time & console.timeEnd
The console.time
and console.timeEnd
methods allow developers to time any routine and get a duration in milliseconds. Since JavaScript performance is becoming increasingly important, it's good to know basic techniques for benchmarking routines. One of the most basic benchmarking tools is console.time
with console.timeEnd
.
console.time
starts the time and console.timeEnd
stops the timer and spits out the duration:
// Kick off the timer
console.time('testForEach');
// (Do some testing of a forEach, for example)
// End the timer, get the elapsed time
console.timeEnd('testForEach');
// 4522.303ms (or whatever time elapsed)
Passing a timer name as the first argument allows you to manage concurrent timers. The console.timeEnd
call immediately spits out the elapsed time in milliseconds.
There are more advanced techniques for performance testing and benchmarking but console.time
/timeEnd
provide a quick manual method for speed testing!
![Create a CSS Cube]()
CSS cubes really showcase what CSS has become over the years, evolving from simple color and dimension directives to a language capable of creating deep, creative visuals. Add animation and you've got something really neat. Unfortunately each CSS cube tutorial I've read is a bit...
![JavaScript Promise API]()
While synchronous code is easier to follow and debug, async is generally better for performance and flexibility. Why "hold up the show" when you can trigger numerous requests at once and then handle them when each is ready? Promises are becoming a big part of the JavaScript world...
![jQuery Link Nudge Plugin]()
A while back I debuted a tasteful mouseover/mouseout technique called link nudging. It started with a MooTools version and shortly thereafter a jQuery version. Just recently Drew Douglass premiered a jQuery plugin that aimed at producing the same type of effect.
![MooTools 1.2 Tooltips: Customize Your Tips]()
I've never met a person that is "ehhhh" about XHTML/javascript tooltips; people seem to love them or hate them. I'm on the love side of things. Tooltips give you a bit more information about something than just the element itself (usually...
no necessary label, the default label is
default