<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>brilliant software &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/brilliant-software/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>Profiling JavaScript with Firebug. console.profile() &#038; console.time()!</title>
		<link>/2010/02/02/profiling-javascript-with-firebug-console-profile-console-time/</link>
		<comments>/2010/02/02/profiling-javascript-with-firebug-console-profile-console-time/#respond</comments>
		<pubDate>Tue, 02 Feb 2010 06:19:50 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[brilliant software]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[JavaScript programmer]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[web apps]]></category>
		<category><![CDATA[web developers]]></category>

		<guid isPermaLink="false">/?p=999</guid>
		<description><![CDATA[Firebug and the console object Although my impression is that most of the web developers use Firefox and most of them are using Firebug, I’m not sure that they use the full potential of this brilliant software. Firebug&#8217;s console view Firebug is a very powerful tool helping those like me doing his job. But what’s &#8230; <a href="/2010/02/02/profiling-javascript-with-firebug-console-profile-console-time/" class="more-link">Continue reading <span class="screen-reader-text">Profiling JavaScript with Firebug. console.profile() &#038; console.time()!</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/02/03/firebugs-console-profile-vs-console-time/" rel="bookmark" title="Firebug&#8217;s console.profile vs console.time">Firebug&#8217;s console.profile vs console.time </a></li>
<li><a href="/2010/02/02/firebugs-console-time-accuracy/" rel="bookmark" title="Firebug&#8217;s console.time() accuracy">Firebug&#8217;s console.time() accuracy </a></li>
<li><a href="/2010/02/12/how-to-detect-a-variable-existence-in-javascript/" rel="bookmark" title="How to detect a variable existence in JavaScript?">How to detect a variable existence in JavaScript? </a></li>
<li><a href="/2012/01/24/javascript-performance-for-vs-while/" rel="bookmark" title="JavaScript Performance: for vs. while">JavaScript Performance: for vs. while </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Firebug and the console object</h2>
<p>Although my impression is that most of the web developers use Firefox and most of them are using Firebug, I’m not sure that they use the full potential of this brilliant software.</p>
<p><a href="/wp-content/uploads/2010/01/logging.gif"><img class="aligncenter size-full wp-image-1001" title="logging" src="/wp-content/uploads/2010/01/logging.gif" alt="" width="430" height="195" srcset="/wp-content/uploads/2010/01/logging.gif 430w, /wp-content/uploads/2010/01/logging-300x136.gif 300w" sizes="(max-width: 430px) 100vw, 430px" /></a></p>
<p><em>Firebug&#8217;s console view</em></p>
<p>Firebug is a very powerful tool helping those like me doing his job. But what’s behind the mostly used Firebug’s tools and what’s in the API.</p>
<h2>console.log()</h2>
<p>For a typical JavaScript programmer the console.log() function is one of his best friends. It can dump useful information in the console tab of the Firebug making everything quite clear. But have you ever asked yourself how to improve your code, how to measure its performance against some constructions.</p>
<h2>Performance of JavaScript</h2>
<p>I’m sure many of us have read enough articles out in the web about JS performance. Nowadays when the web apps become bigger and bigger, this topic is rising from the bottom of the interesting topics pool. Now everybody’s concerned about it’s app performance and speed.</p>
<p>You’ve probably heart about some basic advices. What to use, what not to use. In a short example I’ll mention only that everybody knows that .appendChild is far slower than the innerHTML. But why is that? How can be sure it’s true.</p>
<p>As I wrote recently you should instantiate your new arrays in javascript with the following construction:</p>
<blockquote>
<pre>var a = [];</pre>
</blockquote>
<p>instead of:</p>
<blockquote>
<pre>var a = new Array();</pre>
</blockquote>
<p>but as I’ll write here that’s not always true.</p>
<h2>console.profile()</h2>
<p>One of the useful methods of the Firebug’s console object is the profile() method. It gives you the power to measure timing and performance of any JS function. As described in the Firebug’s web page:</p>
<p><em>The high-fi approach is to use the JavaScript profiler. Just call console.profile() before the code you want to measure, and then console.profileEnd() afterwards. Firebug will log a detailed report about how much time was spent in every function call in between.</em></p>
<p>With the simple construction like:</p>
<blockquote>
<pre>&lt;html&gt;
&lt;body&gt;
&lt;script&gt;
    myFunc = function() {
        var a = [];
    }				

   console.profile();
   myFunc();
   console.profileEnd();
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
</blockquote>
<p><a href="/wp-content/uploads/2010/01/firebug-profile.png"><img class="aligncenter size-full wp-image-1000" title="firebug-profile" src="/wp-content/uploads/2010/01/firebug-profile.png" alt="" width="430" height="152" srcset="/wp-content/uploads/2010/01/firebug-profile.png 430w, /wp-content/uploads/2010/01/firebug-profile-300x106.png 300w" sizes="(max-width: 430px) 100vw, 430px" /></a></p>
<p><em>Firebug&#8217;s profile output</em></p>
<p>The simple problem is that thus you cannot just measure some code that’s not a function. This will result in empty profile output in the console&#8217;s view:</p>
<p><a href="/wp-content/uploads/2010/01/no-activity.png"><img class="alignleft size-full wp-image-1002" title="no-activity" src="/wp-content/uploads/2010/01/no-activity.png" alt="" width="231" height="60" /></a></p>
<p>But hopefully there comes the other method of the console object.</p>
<h2>console.time()</h2>
<p>It gives anything you’d like to know even if it’s not closed into a function.</p>
<p><em><strong>Note</strong>: remember that both profile and time methods goes with their related profileEnd and timeEnd methods. You’re supposed to enclose the chunk of code you measure with that to be sure that the Firebug’s console will stop the profilers on time. </em></p>
<p><em><span style="font-style: normal;">Now you can simply ask the profiler: what is faster?</span></em></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/02/03/firebugs-console-profile-vs-console-time/" rel="bookmark" title="Firebug&#8217;s console.profile vs console.time">Firebug&#8217;s console.profile vs console.time </a></li>
<li><a href="/2010/02/02/firebugs-console-time-accuracy/" rel="bookmark" title="Firebug&#8217;s console.time() accuracy">Firebug&#8217;s console.time() accuracy </a></li>
<li><a href="/2010/02/12/how-to-detect-a-variable-existence-in-javascript/" rel="bookmark" title="How to detect a variable existence in JavaScript?">How to detect a variable existence in JavaScript? </a></li>
<li><a href="/2012/01/24/javascript-performance-for-vs-while/" rel="bookmark" title="JavaScript Performance: for vs. while">JavaScript Performance: for vs. while </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/02/02/profiling-javascript-with-firebug-console-profile-console-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
