RSS 2.0 Feed
Posted on February 10th, 2010 at 06:55 PM by Corey Ballou

I was vastly unaware of the number of useful functions built into Firebug beyond console.log(). The official Firebug site has a brief overview of the available commands which can be found here. Here’s a couple of quick examples to get you going.

You can use console.time() and console.timeEnd() to quickly log the time spent between the two.

console.time();
var str = '';
for (var i = 0; i < 1000; i++) {
    str += i;
}
console.timeEnd();

If you wish to profile the amount of time spent in each function call, you can use console.profile() in conjunction with console.profileEnd():

console.profile();
for (var i = 0; i < 1000; i++) {
    testFunction();
}
console.profileEnd();

function testFunction() {
    // dummy function
}

Lastly, you can call for a stack trace at any point in time by simply calling console.trace().

console.trace();