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!
For maximum performance, we all know we must put our assets on CDN (another domain). Along with those assets are custom web fonts. Unfortunately custom web fonts via CDN (or any cross-domain font request) don't work in Firefox or Internet Explorer (correctly so, by spec) though...
Sooner or later you'll run across a regular expression. With their cryptic syntax, confusing documentation and massive learning curve, most developers settle for copying and pasting them from StackOverflow and hoping they work. But what if you could decode regular expressions and harness their power? In...
The goal of CSS is to allow styling of content and structure within a web page. We all know that, right? As CSS revisions arrive, we're provided more opportunity to control. One of the little known styling option available within the browser is text selection styling.
My team mate Edna Piranha is not only an awesome hacker; she's also a fantastic philosopher! Communication and online interactions is a subject that has kept her mind busy for a long time, and it has also resulted in a bunch of interesting experimental projects...
no necessary label, the default label is
default