<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5403501357146437649</id><updated>2024-08-28T19:40:17.132-07:00</updated><category term="Optimizing"/><category term="arithmetic"/><category term="code"/><category term="optimization"/><category term="tuorial"/><title type='text'>Optimizing Code</title><subtitle type='html'>This blog gives an overview on optimising programs.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://optimizingcode.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5403501357146437649/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://optimizingcode.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Venkat Arun</name><uri>http://www.blogger.com/profile/07989143516356293042</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5403501357146437649.post-2356329284956342985</id><published>2010-10-16T05:04:00.000-07:00</published><updated>2010-12-12T05:18:54.270-08:00</updated><title type='text'>General</title><content type='html'>&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;Today I am just posting whatever comes to my mind. There is no specific topic. So these are just general optimization guidelines, which can be followed.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;h2&gt;What not to optimize&lt;/h2&gt;&lt;/span&gt;&lt;/div&gt;There are many thing which will not yield much even after tedious optimization. There are two chief reasons for this:&lt;div&gt;&lt;ol&gt;&lt;li&gt;It may not need optimizing: optimizing parts of the program which hardly take any of the programs time will not improve the performance much. So only those parts should be optimized which are taking up a lot of the processors time&lt;/li&gt;&lt;li&gt;It might have been automatically optimized. Many compilers align memory, optimize loops and use shifts instead of division where applicable. Optimizing these things will prove to be futile as it is already optimized.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;h2&gt;General Optimization Guidelines&lt;/h2&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Avoid branches as they will force the processor to speculate, which will result in significant performance losses, if the prediction is wrong.&lt;/li&gt;&lt;li&gt;Optimize recursive functions and loops.&lt;/li&gt;&lt;li&gt;Make 1-2 line functions inline, although many compilers do it themselves.&lt;/li&gt;&lt;li&gt;Avoid fancy features like operator overloading and virtual functions, they are more inefficient. They can however e used in areas of programs which do not get executed frequently to make things more readable.&lt;/li&gt;&lt;li&gt;Try not to continually allocate and free memory.&lt;/li&gt;&lt;li&gt;At the same time watch out for memory leaks. For this see the performance tab of the task manager window and watch for a continual increase in memory usage.&lt;/li&gt;&lt;li&gt;Do not compromise modularity for speed except in cases where it is really important.&lt;/li&gt;&lt;li&gt;Concise does not always mean fast.&lt;/li&gt;&lt;li&gt;Do not use recursion where linear algorithms will do.&lt;/li&gt;&lt;li&gt;Do not pass unrequired arguments to functions&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://optimizingcode.blogspot.com/feeds/2356329284956342985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://optimizingcode.blogspot.com/2010/10/general.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5403501357146437649/posts/default/2356329284956342985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5403501357146437649/posts/default/2356329284956342985'/><link rel='alternate' type='text/html' href='http://optimizingcode.blogspot.com/2010/10/general.html' title='General'/><author><name>Venkat Arun</name><uri>http://www.blogger.com/profile/07989143516356293042</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5403501357146437649.post-2067303767811340765</id><published>2010-10-07T01:32:00.001-07:00</published><updated>2010-10-07T01:49:06.768-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arithmetic"/><category scheme="http://www.blogger.com/atom/ns#" term="code"/><category scheme="http://www.blogger.com/atom/ns#" term="optimization"/><category scheme="http://www.blogger.com/atom/ns#" term="Optimizing"/><category scheme="http://www.blogger.com/atom/ns#" term="tuorial"/><title type='text'>Optimal Arithmetic Operations</title><content type='html'>While we write programs, we usually think in terms of the decimal number system. It may seem normal to us, but the computer prefers binary. So doing arithmetic operations that are more binary friendly will help optimize your program.&lt;br /&gt;&lt;br /&gt;It is better to multiply and divide by a power of two rather than some other number. Obviously this should only be done when it does not affect the program execution. The optimization achieved here is because the compiler will replace the division instruction with a shift instruction, which in many processors can be completed in half clock cycle. This is similar to the division and multiplication of a number by 10 in the decimal system.&lt;br /&gt;&lt;br /&gt;A more optimized code can also be obtained by using an&lt;span style=&quot;font-style: italic;&quot;&gt; int&lt;/span&gt; (4 bytes/1 word) rather than a&lt;span style=&quot;font-style: italic;&quot;&gt; char&lt;/span&gt; or a &lt;span style=&quot;font-style: italic;&quot;&gt;byte&lt;/span&gt;, even if your data will fit into 1 byte. This is because many compilers will first convert a &lt;span style=&quot;font-style: italic;&quot;&gt;char&lt;/span&gt; or &lt;span style=&quot;font-style: italic;&quot;&gt;byte&lt;/span&gt; to an &lt;span style=&quot;font-style: italic;&quot;&gt;int&lt;/span&gt; while doing the arithmetic operations and then convert it back again. This leads to slow program execution.</content><link rel='replies' type='application/atom+xml' href='http://optimizingcode.blogspot.com/feeds/2067303767811340765/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://optimizingcode.blogspot.com/2010/10/optimal-arithmetic-operations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5403501357146437649/posts/default/2067303767811340765'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5403501357146437649/posts/default/2067303767811340765'/><link rel='alternate' type='text/html' href='http://optimizingcode.blogspot.com/2010/10/optimal-arithmetic-operations.html' title='Optimal Arithmetic Operations'/><author><name>Venkat Arun</name><uri>http://www.blogger.com/profile/07989143516356293042</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5403501357146437649.post-6070102720441720175</id><published>2010-09-04T03:28:00.000-07:00</published><updated>2010-09-04T03:43:03.167-07:00</updated><title type='text'></title><content type='html'>Hello, I have downloaded Intel® 64 And IA-32 Optimizations Manual, and I got to know some nice tricks to optimize code. So I will be posting them one by one.&lt;br /&gt;&lt;br /&gt;This is the first trick that I got from this manual:&lt;br /&gt;&lt;br /&gt;Try to keep your loops less than 16 instructions long. If you do this, then the whole loop gets stored in the Instruction Queue itself, thus avoiding many penalties. This also allows the Instruction Fetch and pre-decode sections of the processor to remain idle, thus reducing power consumption.&lt;br /&gt;However the manual also says that loop unrolling can be in many cases faster than trying to fit the whole loop in the instruction queue. So to take the right decision, profile your code and see which works faster.</content><link rel='replies' type='application/atom+xml' href='http://optimizingcode.blogspot.com/feeds/6070102720441720175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://optimizingcode.blogspot.com/2010/09/hello-i-have-downloaded-intel-64-and-ia.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5403501357146437649/posts/default/6070102720441720175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5403501357146437649/posts/default/6070102720441720175'/><link rel='alternate' type='text/html' href='http://optimizingcode.blogspot.com/2010/09/hello-i-have-downloaded-intel-64-and-ia.html' title=''/><author><name>Venkat Arun</name><uri>http://www.blogger.com/profile/07989143516356293042</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5403501357146437649.post-7578900334402743918</id><published>2010-08-22T04:00:00.000-07:00</published><updated>2010-08-22T04:00:03.604-07:00</updated><title type='text'>Very Very Quick Sort!!</title><content type='html'>Welcome back!!&lt;br /&gt;This is a cool algorithm for super fast sorting. This algorithm sorts an array of numbers, &lt;span style=&quot;font-style: italic;&quot;&gt;nos&lt;/span&gt;, whose values range from 0 to &lt;span style=&quot;font-style: italic;&quot;&gt;n&lt;/span&gt;, the result is stored in &lt;span style=&quot;font-style: italic;&quot;&gt;res&lt;/span&gt; The size of &lt;span style=&quot;font-style: italic;&quot;&gt;nos&lt;/span&gt; is &lt;span style=&quot;font-style: italic;&quot;&gt;x&lt;/span&gt;&lt;br /&gt;Declare array &lt;span style=&quot;font-style: italic;&quot;&gt;arr&lt;/span&gt; of size &lt;span style=&quot;font-style: italic;&quot;&gt;n&lt;/span&gt;&lt;br /&gt;Initialise &lt;span style=&quot;font-style: italic;&quot;&gt;arr&lt;/span&gt; to 0&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Loop from 0 to &lt;span style=&quot;font-style: italic;&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;/span&gt; using counter &lt;span style=&quot;font-style: italic;&quot;&gt;c&lt;/span&gt;&lt;br /&gt; &lt;span style=&quot;font-style: italic;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;font-style: italic;&quot;&gt;nos&lt;/span&gt;[&lt;span style=&quot;font-style: italic;&quot;&gt;c&lt;/span&gt;]] ++&lt;br /&gt;End loop&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Loop from 0 to &lt;span style=&quot;font-style: italic;&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;/span&gt; using counter &lt;span style=&quot;font-style: italic;&quot;&gt;c&lt;/span&gt;&lt;br /&gt; If &lt;span style=&quot;font-style: italic;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;font-style: italic;&quot;&gt;c&lt;/span&gt;] &gt; 0&lt;br /&gt;    Loop from 0 to &lt;span style=&quot;font-style: italic;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;font-style: italic;&quot;&gt;c&lt;/span&gt;] using counter a&lt;br /&gt;       &lt;span style=&quot;font-style: italic;&quot;&gt;res&lt;/span&gt;[&lt;span style=&quot;font-style: italic;&quot;&gt;c&lt;/span&gt;+&lt;span style=&quot;font-style: italic;&quot;&gt;a&lt;/span&gt;] = &lt;span style=&quot;font-style: italic;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;font-style: italic;&quot;&gt;c&lt;/span&gt;]&lt;br /&gt;    End loop&lt;br /&gt; End if&lt;br /&gt;End loop&lt;/blockquote&gt;This algorithm trades speed for memory usage, and it is impractical to use, if the range of values to be sorted is large. Memory can be saved if the removal of repititions is not an issue. For example if 1, 9, 5, 9, 4, 4, 6, 7 can be sorted as 1, 4, 5, 6, 7, 9, where the repititions of 4 and 9 are removed. In this case one bit for each value is enough, for indicating whether a vlue is present or not.</content><link rel='replies' type='application/atom+xml' href='http://optimizingcode.blogspot.com/feeds/7578900334402743918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://optimizingcode.blogspot.com/2010/08/very-very-quick-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5403501357146437649/posts/default/7578900334402743918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5403501357146437649/posts/default/7578900334402743918'/><link rel='alternate' type='text/html' href='http://optimizingcode.blogspot.com/2010/08/very-very-quick-sort.html' title='Very Very Quick Sort!!'/><author><name>Venkat Arun</name><uri>http://www.blogger.com/profile/07989143516356293042</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5403501357146437649.post-2463303000121865529</id><published>2010-08-21T12:50:00.000-07:00</published><updated>2010-08-21T13:01:44.486-07:00</updated><title type='text'>Hotspots</title><content type='html'>In this post we&#39;ll discuss the detection of hotspots in a program.&lt;br /&gt;A hotspot is a place in the program where it is spending a lot of time. Thus optimising hotspots will have higher yield than optimising other areas of the program.&lt;br /&gt;&lt;br /&gt;Profilers can be used to detect hotspots, one such profiler is the AMD CodeAnalyst. It is a free software provided by AMD to test programs for AMD machines. The instructions on how to use it are quite clear, and the download is about 50MB.&lt;br /&gt;&lt;br /&gt;I have also heard a lot about Intel&#39;s VTune, and its features sound impressive. But I have not tested it because of its high cost. VTune even lets you to go inside a machine instruction and see what is happening there. The maximum resolution of Code Analyst, however is only one machine instruction.</content><link rel='replies' type='application/atom+xml' href='http://optimizingcode.blogspot.com/feeds/2463303000121865529/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://optimizingcode.blogspot.com/2010/08/hotspots.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5403501357146437649/posts/default/2463303000121865529'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5403501357146437649/posts/default/2463303000121865529'/><link rel='alternate' type='text/html' href='http://optimizingcode.blogspot.com/2010/08/hotspots.html' title='Hotspots'/><author><name>Venkat Arun</name><uri>http://www.blogger.com/profile/07989143516356293042</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5403501357146437649.post-8949940385983639533</id><published>2010-07-21T09:35:00.000-07:00</published><updated>2010-07-24T03:15:55.336-07:00</updated><title type='text'>Code Optimization Techniques</title><content type='html'>Code optimization is a much neglected activity these days, because of the ever growing computing speed. But if done properly, code optimization can be very fast, effective and pleasing. I will discuss some methods of code optimization here:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Loop Unrolling:&lt;/span&gt;&lt;br /&gt;Loop unrolling involves, copying the loop body a few times, so that the number of iterations are decreased. To understand this, let us look at a program which adds an array of 400 items&lt;br /&gt;&lt;br /&gt;Normal loop:&lt;br /&gt;&lt;blockquote&gt;for(int i = 0;i &amp;lt; 400;i++){&lt;/blockquote&gt;&lt;blockquote&gt;   x += arr[i];&lt;/blockquote&gt;&lt;blockquote&gt;}&lt;/blockquote&gt;&lt;br /&gt;Unrolled loop:&lt;br /&gt;&lt;blockquote&gt;for(int i = 0;i &amp;lt; 100;i+=4){&lt;/blockquote&gt;&lt;blockquote&gt;   x += arr[i];&lt;/blockquote&gt;&lt;blockquote&gt;   x += arr[i+1];&lt;/blockquote&gt;&lt;blockquote&gt;   x += arr[i+2];&lt;/blockquote&gt;&lt;blockquote&gt;   x += arr[i+3];&lt;/blockquote&gt;&lt;blockquote&gt;}&lt;/blockquote&gt;&lt;br /&gt;The second (unrolled) loop will run much faster than the first, because there are fewer jumps and compare instructions. The number of times a loop is unrolled (here it is 4) should be 2 or 4 for maximum efficiency.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Moving Stuff Out Of Loops&lt;/b&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;Generally loops and recursive functions are the most time consuming parts of a program, so the body of loops and recursive functions need to be shortened. For example, the following program snippet makes &#39;n&#39; number of copies of a string &#39;s&#39;, and stores it in an array &#39;arr&#39;:&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;char *arr = new char*[n];&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;for(int i = 0;i &amp;lt; n;i++){&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;   arr[i] = new char[strlen(s)+1];&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;   strcpy(arr[i], s);&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;You might have noticed that we are calling the strlen function inside the loop, because of which it gets executed &#39;n&#39; times. This is unnecessary as the length of the string &#39;s&#39; does not change, therefore a simple modification can make the program run much faster. Here is the modified code:&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;char *arr = new char*[n];&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;int len = strlen(s)+1;&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;for(int i = 0;i &amp;lt; n;i++){&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;   arr[i] = new char[len];&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;   strcpy(arr[i], s);&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;It is important to note that some compilers are smart enough to notice this error, and might move the strlen function call out of the loop body. In such a case, you will not notice a performance increase, because the program is already optimized!!&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;    style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;font-size:13px;color:#333333;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;    style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;    line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;font-size:13px;color:#333333;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;   line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;b&gt;Optimizing Sequential Memory Reads&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;   line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;There is &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt; vast scope for optimization while reading memory sequentially. The following unoptimized program snippet finds the maximum out of 10000 numbers (char&#39;s):&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;   line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;char *arr;//*arr is pointing to a 10000 byte array&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;max = arr[0];&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;for(int i = 1;i &amp;lt; 10000;i++){&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;    if(arr[i] &amp;gt; max)max = arr[i];&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot; ;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse; line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot; ;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse; line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;The following program does that much more efficiently:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: collapse; line-height: 18px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot; ;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;div   style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border-collapse: separate;   line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;font-family:&#39;Times New Roman&#39;;color:black;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;char *arr;//*arr is pointing to a 10000 byte array&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div   style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border-collapse: separate;   line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;font-family:&#39;Times New Roman&#39;;color:black;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;max = arr[0];&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div   style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border-collapse: separate;   line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;font-family:&#39;Times New Roman&#39;;color:black;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;for(int i = 1;i &amp;lt; 10000;i+=64){&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div   style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border-collapse: separate;   line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;font-family:&#39;Times New Roman&#39;;color:black;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;   if(arr[i] &amp;gt; max)max = arr[i];&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div   style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border-collapse: separate;   line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;font-family:&#39;Times New Roman&#39;;color:black;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div   style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border-collapse: separate;   line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;font-family:&#39;Times New Roman&#39;;color:black;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;for(int i = 1;i &amp;lt; 10000;i++){   //this will read every 64th element the second time, but                                 the overhead is small&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div   style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border-collapse: separate;   line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;font-family:&#39;Times New Roman&#39;;color:black;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;   if(arr[i] &amp;gt; max)max = arr[i];&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div    style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border-collapse: separate;    line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;font-family:&#39;Times New Roman&#39;;font-size:medium;color:black;&quot;&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;   line-height: 18px;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;   style=&quot; ;font-family:&#39;trebuchet ms&#39;, verdana, arial, sans-serif;color:#333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse; line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;Explaining why this is faster is out of the scope of this blog. But if you read about how memory (RAM) is structured you will notice that it can handle 4 or more sequential memory requests in parallel, so the memory is loaded into the cache, after which it is read with hardly any delay.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://optimizingcode.blogspot.com/feeds/8949940385983639533/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://optimizingcode.blogspot.com/2010/07/code-optimization-is-much-neglected.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5403501357146437649/posts/default/8949940385983639533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5403501357146437649/posts/default/8949940385983639533'/><link rel='alternate' type='text/html' href='http://optimizingcode.blogspot.com/2010/07/code-optimization-is-much-neglected.html' title='Code Optimization Techniques'/><author><name>Venkat Arun</name><uri>http://www.blogger.com/profile/07989143516356293042</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>