What is the best way to profile javascript execution?

67,712

Solution 1

Firebug

Firebug provides a highly detailed profiling report. It will tell you how long each method invocation takes in a giant (detailed) table.

console.profile([title])
//also see
console.trace()

You need to call console.profileEnd () to end your profile block. See the console API here: http://getfirebug.com/wiki/index.php/Console_API

Blackbird

Blackbird (official site) also has a simpler profiler (can be downloaded from here)

Solution 2

Chrome's Developer Tools has a built-in profiler.

Solution 3

Although Firebug has been mentioned, one additional thing you would want to look at with Firebug is a plugin for Firebug called FireUnit; John Resig talks about it in this blog post:

JavaScript Function Call Profiling

Hope that helps.

Solution 4

Safari 4's web inspector also includes a profiler (although the version in the nightlies is improved wrt. recursive function calls). The Web Inspector also supports Firebug's profiler APIs.

Solution 5

Firebug+Firefox is a must have. And IE 8's developer toolbar also has a profiler built in (IE 8 ships with the developer toolbar).

Share:
67,712
Norbert Hartl
Author by

Norbert Hartl

senior development unit still fully functional

Updated on November 24, 2020

Comments

  • Norbert Hartl
    Norbert Hartl over 3 years

    Is there a good profiler for javascript? I know that firebug has some support for profiling code. But I want to determine stats on a longer scale. Imagine you are building a lot of javascript code and you want to determine what are actually the bottlenecks in the code. At first I want to see profile stats of every javascript function and execution time. Next would be including DOM functions. This combined with actions that slows things down like operation on the rendering tree would be perfect. I think this would give a good impression if the performance is killed in my code, in DOM preparation or in updates to the rendering tree/visual.

    Is there something close to what I want? Or what would be the best tool to achieve the most of what I've described? Would it be a self compiled browser plus javascript engine enhanced by profile functionality?

  • Norbert Hartl
    Norbert Hartl almost 15 years
    I wrote that I know firefox. I want to have more stats from the browser that is influenting the execution of the javascript.
  • Chris B
    Chris B almost 15 years
    Ditto on Firebug, and you can profile straight from the console if you don't want to code it.
  • Sasha Chedygov
    Sasha Chedygov almost 15 years
    Firebug is just about the best tool you'll get.
  • olliej
    olliej almost 15 years
    Same thing works in the Safari Web Inspector
  • JMTyler
    JMTyler over 11 years
    +1, Speed Tracer is good, and it's important (as the OP mentioned) to profile your code in more than just Firefox to see how the individual browser affects it.
  • JMTyler
    JMTyler over 11 years
    Firebug is good and all, but I can't believe there are so many people here chanting "Firebug, Firebug!" right after the OP said explicitly that he wants to profile his code from multiple browsers.
  • T.Todua
    T.Todua over 7 years
    Here seems to be download link - github.com/jeresig/fireunit/tree/master
  • T.Todua
    T.Todua over 7 years
    please, instruction how to install that as addon/extension in browser.