Timing a JavaScript event
There are times when it's useful to know how long a particular piece of code takes to execute. The example below is taken from a project that renders document pages to screen, knowing how long the process took was immensely valuable.
Thanks to Chrome's timeline this is pretty easy to accomplish.
// start timer.
console.time('render pages');
this.model.get('pages').each( function ( page ) {
$('.pages', this.el).append( new PageView({ model: page }).render().el );
}, this);
// end timer.
console.timeEnd('render pages');
The next time you render the page, the following will appear in the console.

References
Chrome Developer Tools Documentation
Written by Paul Osborne
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#