<?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: Improving fwrite performance	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/improving-fwrite-performance/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/improving-fwrite-performance?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=improving-fwrite-performance</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Wed, 17 May 2023 18:25:24 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.3</generator>
	<item>
		<title>
		By: Michelle Kline		</title>
		<link>https://undocumentedmatlab.com/articles/improving-fwrite-performance#comment-521608</link>

		<dc:creator><![CDATA[Michelle Kline]]></dc:creator>
		<pubDate>Wed, 17 May 2023 18:25:24 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3731#comment-521608</guid>

					<description><![CDATA[*edit*
tip about fopen(), not about fwrite(). &#039;Wb&#039; vs. &#039;wb&#039;]]></description>
			<content:encoded><![CDATA[<p>*edit*<br />
tip about fopen(), not about fwrite(). &#8216;Wb&#8217; vs. &#8216;wb&#8217;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Michelle Kline		</title>
		<link>https://undocumentedmatlab.com/articles/improving-fwrite-performance#comment-521607</link>

		<dc:creator><![CDATA[Michelle Kline]]></dc:creator>
		<pubDate>Wed, 17 May 2023 18:22:56 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3731#comment-521607</guid>

					<description><![CDATA[Thank you, Yair! With this previously-unknown-to-me tip about fwrite() performance, you have saved me literally hours of processing time. 
Michelle Kline
Department of Radiology and Imaging Research
University of Utah]]></description>
			<content:encoded><![CDATA[<p>Thank you, Yair! With this previously-unknown-to-me tip about fwrite() performance, you have saved me literally hours of processing time.<br />
Michelle Kline<br />
Department of Radiology and Imaging Research<br />
University of Utah</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Kerim		</title>
		<link>https://undocumentedmatlab.com/articles/improving-fwrite-performance#comment-444101</link>

		<dc:creator><![CDATA[Kerim]]></dc:creator>
		<pubDate>Sun, 30 Sep 2018 20:03:05 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3731#comment-444101</guid>

					<description><![CDATA[Very surprising deatail, thank you.
But it&#039;s strange that you didn&#039;t mention a possibility to improve read/write perfomance by adjusting Java. Is that real?]]></description>
			<content:encoded><![CDATA[<p>Very surprising deatail, thank you.<br />
But it&#8217;s strange that you didn&#8217;t mention a possibility to improve read/write perfomance by adjusting Java. Is that real?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Joe V		</title>
		<link>https://undocumentedmatlab.com/articles/improving-fwrite-performance#comment-348705</link>

		<dc:creator><![CDATA[Joe V]]></dc:creator>
		<pubDate>Fri, 01 May 2015 15:18:09 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3731#comment-348705</guid>

					<description><![CDATA[On a related note: When reading binary files, don&#039;t use fseek inside a loop if you can avoid it -- it&#039;s very slow. In almost all cases I&#039;ve tried, it&#039;s faster to do
&lt;pre lang=&quot;matlab&quot;&gt;fread(fid, N, &#039;*uint8&#039;);&lt;/pre&gt; and throw away the result than to do
&lt;pre lang=&quot;matlab&quot;&gt;fseek(fid, N, &#039;cof&#039;);&lt;/pre&gt; (although, of course, you can&#039;t move backwards in a file using fread, so you&#039;re stuck with fseek in that case). This seems to be a limitation of the fseek function in the C library, and it can be especially egregious on network drives.

In general, when doing binary file I/O, touch the file as few times as possible. Reading or writing the entire file in one go is fastest. Make use of fread&#039;s (and fwrite&#039;s) skip parameter when possible. When performance is truly critical, read the data into memory as a uint8 array and parse it yourself using typecast, rather than relying on fread to do the parsing for you. It can be complicated and tricky and error-prone, but it&#039;s tons faster.]]></description>
			<content:encoded><![CDATA[<p>On a related note: When reading binary files, don&#8217;t use fseek inside a loop if you can avoid it &#8212; it&#8217;s very slow. In almost all cases I&#8217;ve tried, it&#8217;s faster to do</p>
<pre lang="matlab">fread(fid, N, '*uint8');</pre>
<p> and throw away the result than to do</p>
<pre lang="matlab">fseek(fid, N, 'cof');</pre>
<p> (although, of course, you can&#8217;t move backwards in a file using fread, so you&#8217;re stuck with fseek in that case). This seems to be a limitation of the fseek function in the C library, and it can be especially egregious on network drives.</p>
<p>In general, when doing binary file I/O, touch the file as few times as possible. Reading or writing the entire file in one go is fastest. Make use of fread&#8217;s (and fwrite&#8217;s) skip parameter when possible. When performance is truly critical, read the data into memory as a uint8 array and parse it yourself using typecast, rather than relying on fread to do the parsing for you. It can be complicated and tricky and error-prone, but it&#8217;s tons faster.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Explicit multi-threading in Matlab &#8211; part 1 &#124; Undocumented Matlab		</title>
		<link>https://undocumentedmatlab.com/articles/improving-fwrite-performance#comment-314890</link>

		<dc:creator><![CDATA[Explicit multi-threading in Matlab &#8211; part 1 &#124; Undocumented Matlab]]></dc:creator>
		<pubDate>Wed, 19 Feb 2014 20:18:29 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3731#comment-314890</guid>

					<description><![CDATA[[...] slow for our specific needs. We could perhaps improve it a bit with some fancy tricks for save or fwrite. But let&#8217;s take a different approach today, using multi-threading:Using Java threadsMatlab [...]]]></description>
			<content:encoded><![CDATA[<p>[&#8230;] slow for our specific needs. We could perhaps improve it a bit with some fancy tricks for save or fwrite. But let&#8217;s take a different approach today, using multi-threading:Using Java threadsMatlab [&#8230;]</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Anonymous		</title>
		<link>https://undocumentedmatlab.com/articles/improving-fwrite-performance#comment-297766</link>

		<dc:creator><![CDATA[Anonymous]]></dc:creator>
		<pubDate>Fri, 22 Nov 2013 09:37:59 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3731#comment-297766</guid>

					<description><![CDATA[Just wonderful! As usual :) I&#039;m very likely to start teaching this in my Matlab classes...]]></description>
			<content:encoded><![CDATA[<p>Just wonderful! As usual 🙂 I&#8217;m very likely to start teaching this in my Matlab classes&#8230;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/improving-fwrite-performance#comment-207350</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Wed, 29 May 2013 19:47:54 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3731#comment-207350</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/improving-fwrite-performance#comment-207348&quot;&gt;Isaac Stoddard&lt;/a&gt;.

@Isaac - I first posted &lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/14773-statusbar&quot; rel=&quot;nofollow&quot;&gt;&lt;i&gt;&lt;b&gt;statusbar&lt;/b&gt;&lt;/i&gt;&lt;/a&gt; over 6 years ago, in April 2007...

Thanks for the coffee :-)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/improving-fwrite-performance#comment-207348">Isaac Stoddard</a>.</p>
<p>@Isaac &#8211; I first posted <a href="http://www.mathworks.com/matlabcentral/fileexchange/14773-statusbar" rel="nofollow"><i><b>statusbar</b></i></a> over 6 years ago, in April 2007&#8230;</p>
<p>Thanks for the coffee 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Isaac Stoddard		</title>
		<link>https://undocumentedmatlab.com/articles/improving-fwrite-performance#comment-207348</link>

		<dc:creator><![CDATA[Isaac Stoddard]]></dc:creator>
		<pubDate>Wed, 29 May 2013 19:28:18 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3731#comment-207348</guid>

					<description><![CDATA[I went through this tuning effort at my previous job about 4 years ago, in 2007b era. 
I would have wished for the statusbar. (Or had you published it to the software library @ TMW?)

Thanks for the blog, and enjoy a cup of coffee!]]></description>
			<content:encoded><![CDATA[<p>I went through this tuning effort at my previous job about 4 years ago, in 2007b era.<br />
I would have wished for the statusbar. (Or had you published it to the software library @ TMW?)</p>
<p>Thanks for the blog, and enjoy a cup of coffee!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jan Simon		</title>
		<link>https://undocumentedmatlab.com/articles/improving-fwrite-performance#comment-205558</link>

		<dc:creator><![CDATA[Jan Simon]]></dc:creator>
		<pubDate>Wed, 22 May 2013 21:33:19 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3731#comment-205558</guid>

					<description><![CDATA[Thanks to explaining this feature.
There has been a &#039;b&#039; flag for the permissions in FOPEN in Matlab 5.3, but it has been removed from the documentation for higher versions. Now a missing &#039;t&#039; is enough to trigger the binary mode.

It is a pleasure to remind you, Yair, that you use an undocumented feature.]]></description>
			<content:encoded><![CDATA[<p>Thanks to explaining this feature.<br />
There has been a &#8216;b&#8217; flag for the permissions in FOPEN in Matlab 5.3, but it has been removed from the documentation for higher versions. Now a missing &#8216;t&#8217; is enough to trigger the binary mode.</p>
<p>It is a pleasure to remind you, Yair, that you use an undocumented feature.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Improving save performance &#124; Undocumented Matlab		</title>
		<link>https://undocumentedmatlab.com/articles/improving-fwrite-performance#comment-199516</link>

		<dc:creator><![CDATA[Improving save performance &#124; Undocumented Matlab]]></dc:creator>
		<pubDate>Wed, 08 May 2013 19:44:36 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=3731#comment-199516</guid>

					<description><![CDATA[[...] Two weeks ago I posted an article about improving fwrite&#039;s performance [...]]]></description>
			<content:encoded><![CDATA[<p>[&#8230;] Two weeks ago I posted an article about improving fwrite&#8217;s performance [&#8230;]</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
