<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: What Are You Really Measuring?</title>
	<atom:link href="http://blogs.mathworks.com/loren/2006/07/12/what-are-you-really-measuring/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2006/07/12/what-are-you-really-measuring/</link>
	<description>Loren Shure works on design of the MATLAB language at MathWorks. She writes here about once a week on MATLAB programming and related topics.</description>
	<lastBuildDate>Fri, 17 Feb 2012 13:41:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Daniel</title>
		<link>http://blogs.mathworks.com/loren/2006/07/12/what-are-you-really-measuring/#comment-30564</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Wed, 02 Sep 2009 15:11:32 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=45#comment-30564</guid>
		<description>Interesting. The fact that Matlab does funky stuff in the for-loop explains why some stuff I tried to do once didn&#039;t work.</description>
		<content:encoded><![CDATA[<p>Interesting. The fact that Matlab does funky stuff in the for-loop explains why some stuff I tried to do once didn&#8217;t work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Srini</title>
		<link>http://blogs.mathworks.com/loren/2006/07/12/what-are-you-really-measuring/#comment-4327</link>
		<dc:creator>Srini</dc:creator>
		<pubDate>Mon, 31 Jul 2006 01:00:05 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=45#comment-4327</guid>
		<description>Constructs like if(1==a) above, where the literal is to the left of the &quot;==&quot; help prevent accidents like (if(a=1)). Faster in the sense that it&#039;ll save bug fixing time :)</description>
		<content:encoded><![CDATA[<p>Constructs like if(1==a) above, where the literal is to the left of the &#8220;==&#8221; help prevent accidents like (if(a=1)). Faster in the sense that it&#8217;ll save bug fixing time :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/07/12/what-are-you-really-measuring/#comment-3579</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Mon, 17 Jul 2006 18:46:43 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=45#comment-3579</guid>
		<description>Sia-

I fixed my typo in the comment above.  I had compared /2 and *.5 in my timings and saw little difference.  But I see some difference with your first set of numbers (but much smaller than the 30% you are seeing).  Thanks for the interesting test cases.
&lt;p&gt;
There are obvious ways to vectorize some codes like these, but you can&#039;t always do so.

--Loren</description>
		<content:encoded><![CDATA[<p>Sia-</p>
<p>I fixed my typo in the comment above.  I had compared /2 and *.5 in my timings and saw little difference.  But I see some difference with your first set of numbers (but much smaller than the 30% you are seeing).  Thanks for the interesting test cases.</p>
<p>
There are obvious ways to vectorize some codes like these, but you can&#8217;t always do so.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sia</title>
		<link>http://blogs.mathworks.com/loren/2006/07/12/what-are-you-really-measuring/#comment-3578</link>
		<dc:creator>Sia</dc:creator>
		<pubDate>Mon, 17 Jul 2006 18:33:06 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=45#comment-3578</guid>
		<description>Loren, It&#039;s not what I meant. you should use / instead of the *. I use R14 (no service pack) on a 2.4 XP laptop 1Gig Ram, please replace your code with this

clc
clear all;
N = 1;
M = magic(2000);
K = zeros(size(M));
t = cputime;
for num = 1:N,
    K = M*.272423;
end
cputime-t
t = cputime;
for num = 1:N,
    K = M/3.67076;
end
cputime-t


on mine it shows 30% better performance for * , however it is really dependant on the case you are solving. sometimes I see 300% improvement.

for the a==1 case I wrote this

clc;
clear all;

t=cputime;

for i=1:20000000
    for j=i:5
        if 2==j
            alpha=200;
        end
    end
end
cputime-t

clear all;
t=cputime;
for i=1:20000000
    for j=i:5
        if j==2
            alpha=200;
        end
    end
end
cputime-t


the difference was just 2 sec in 15 sec, but at least showed that the 1==a case was faster

have a good week</description>
		<content:encoded><![CDATA[<p>Loren, It&#8217;s not what I meant. you should use / instead of the *. I use R14 (no service pack) on a 2.4 XP laptop 1Gig Ram, please replace your code with this</p>
<p>clc<br />
clear all;<br />
N = 1;<br />
M = magic(2000);<br />
K = zeros(size(M));<br />
t = cputime;<br />
for num = 1:N,<br />
    K = M*.272423;<br />
end<br />
cputime-t<br />
t = cputime;<br />
for num = 1:N,<br />
    K = M/3.67076;<br />
end<br />
cputime-t</p>
<p>on mine it shows 30% better performance for * , however it is really dependant on the case you are solving. sometimes I see 300% improvement.</p>
<p>for the a==1 case I wrote this</p>
<p>clc;<br />
clear all;</p>
<p>t=cputime;</p>
<p>for i=1:20000000<br />
    for j=i:5<br />
        if 2==j<br />
            alpha=200;<br />
        end<br />
    end<br />
end<br />
cputime-t</p>
<p>clear all;<br />
t=cputime;<br />
for i=1:20000000<br />
    for j=i:5<br />
        if j==2<br />
            alpha=200;<br />
        end<br />
    end<br />
end<br />
cputime-t</p>
<p>the difference was just 2 sec in 15 sec, but at least showed that the 1==a case was faster</p>
<p>have a good week</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/07/12/what-are-you-really-measuring/#comment-3557</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Mon, 17 Jul 2006 11:12:49 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=45#comment-3557</guid>
		<description>Sia-

I don&#039;t know which version of MATLAB you are using or how you are doing your timing.  I used R2006a and ran this script:

&lt;pre class=&quot;code&quot;&gt;
N = 1;
M = magic(2000);
K = zeros(size(M));
t = cputime;
for num = 1:N,
    K = M*0.5;
end
cputime-t
t = cputime;
for num = 1:N,
    K = M/2.0;
end
cputime-t
&lt;/pre&gt;

&lt;p&gt;
and I basically see no difference in scalar multiplication vs. division.
&lt;/p&gt;
I similarly tried timing &lt;kbd&gt;1==a&lt;/kbd&gt; vs. &lt;kbd&gt;a==1&lt;/kbd&gt; and found no difference.  I am using a Windows XP laptop.</description>
		<content:encoded><![CDATA[<p>Sia-</p>
<p>I don&#8217;t know which version of MATLAB you are using or how you are doing your timing.  I used R2006a and ran this script:</p>
<pre class="code">
N = 1;
M = magic(2000);
K = zeros(size(M));
t = cputime;
for num = 1:N,
    K = M*0.5;
end
cputime-t
t = cputime;
for num = 1:N,
    K = M/2.0;
end
cputime-t
</pre>
<p>
and I basically see no difference in scalar multiplication vs. division.
</p>
<p>I similarly tried timing <kbd>1==a</kbd> vs. <kbd>a==1</kbd> and found no difference.  I am using a Windows XP laptop.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sia</title>
		<link>http://blogs.mathworks.com/loren/2006/07/12/what-are-you-really-measuring/#comment-3438</link>
		<dc:creator>Sia</dc:creator>
		<pubDate>Fri, 14 Jul 2006 20:38:47 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=45#comment-3438</guid>
		<description>Well it&#039;s not exactly a timing issue but I have something to tell about my experience with matlab performance. I brought two of my habits from FORTRAN programming to this amazing Matlab world. 

the first is most of the times it improves the speed dramatically if you use * instead of / if the Denominator is a constant for example instead of a/2 most of the times it helps if you use a*.5 (it makes sense but most of the times we forget to use it)

And one myth is it is better to write your if statements like this &#039;if 1==a&#039; instead of &#039;if a==1&#039; however I still don&#039;t know if it is just a myth or not

And probably everyone knows how to use &amp;&amp; ;)</description>
		<content:encoded><![CDATA[<p>Well it&#8217;s not exactly a timing issue but I have something to tell about my experience with matlab performance. I brought two of my habits from FORTRAN programming to this amazing Matlab world. </p>
<p>the first is most of the times it improves the speed dramatically if you use * instead of / if the Denominator is a constant for example instead of a/2 most of the times it helps if you use a*.5 (it makes sense but most of the times we forget to use it)</p>
<p>And one myth is it is better to write your if statements like this &#8216;if 1==a&#8217; instead of &#8216;if a==1&#8242; however I still don&#8217;t know if it is just a myth or not</p>
<p>And probably everyone knows how to use &amp;&amp; ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/07/12/what-are-you-really-measuring/#comment-3335</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 13 Jul 2006 13:14:07 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=45#comment-3335</guid>
		<description>Steve-

Regular colon notation in for loops fits into the paren behavior.

--Loren</description>
		<content:encoded><![CDATA[<p>Steve-</p>
<p>Regular colon notation in for loops fits into the paren behavior.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Amphlett</title>
		<link>http://blogs.mathworks.com/loren/2006/07/12/what-are-you-really-measuring/#comment-3334</link>
		<dc:creator>Steve Amphlett</dc:creator>
		<pubDate>Thu, 13 Jul 2006 12:44:06 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=45#comment-3334</guid>
		<description>I had often wondered about the use of 1:Inf in a for loop.  So now I know.  Thanks.  Which category does 

  for k=1:theEnd 

fit?  Is it square or paren?

- Steve</description>
		<content:encoded><![CDATA[<p>I had often wondered about the use of 1:Inf in a for loop.  So now I know.  Thanks.  Which category does </p>
<p>  for k=1:theEnd </p>
<p>fit?  Is it square or paren?</p>
<p>- Steve</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/07/12/what-are-you-really-measuring/#comment-3331</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 13 Jul 2006 11:02:32 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=45#comment-3331</guid>
		<description>Sorry for the truncation on the first release of this article.

--Loren</description>
		<content:encoded><![CDATA[<p>Sorry for the truncation on the first release of this article.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
</channel>
</rss>

