Difference between revisions of "Profile"

From FirebugWiki
Jump to: navigation, search
m (Fixed link to Profiler)
m (Added categories)
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
  
 
To stop profiling use <code>[[profileEnd|profileEnd()]]</code>.
 
To stop profiling use <code>[[profileEnd|profileEnd()]]</code>.
 +
 +
This command is a shortcut for the [[console.profile]] API.
  
 
== Syntax ==
 
== Syntax ==
Line 7: Line 9:
 
profile([title])
 
profile([title])
 
</source>
 
</source>
 
== Parameters ==
 
=== title ===
 
Summary for the profiler output.
 
 
This is displayed above the table including the statistics.
 
 
== Examples ==
 
<source lang="javascript">
 
function getById(id)
 
{
 
    return document.getElementById(id);
 
}
 
 
function getViaSelector(id)
 
{
 
    return document.querySelector(id);
 
}
 
 
var numberOfCalls = 10000;
 
 
console.profile("getElementById() vs. querySelector()");
 
for (var i=0; i<numberOfCalls; ++i)
 
    getById("test");
 
for (var i=0; i<numberOfCalls; ++i)
 
    getViaSelector("test");
 
console.profileEnd();
 
</source>
 
 
This will compare the speed of the function <code>document.getElementById()</code> with the function <code>document.querySelector()</code>. The output of that code will look like this:
 
 
[[file:profilerOutputExample.png]]
 
  
 
== See also ==
 
== See also ==
 
* [[profileEnd]]
 
* [[profileEnd]]
 
* [[Command Line API]]
 
* [[Command Line API]]
 +
 +
[[Category:Firebug]]
 +
[[Category:UI]]
 +
[[Category:API]]

Latest revision as of 16:06, 21 November 2013

Turns the JavaScript CPU profiler on, which creates detailed statistics about function calls.

To stop profiling use profileEnd().

This command is a shortcut for the console.profile API.

Syntax[edit]

profile([title])

See also[edit]