<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Segment7: Marshal.load Speed</title>
    <link>http://blog.segment7.net/articles/2006/05/02/marshal-load-speed</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>The Blog</description>
    <item>
      <title>Marshal.load Speed</title>
      <description>&lt;pre&gt;&lt;code&gt;File.open 'dump' do |fp| Marshal.load fp end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Is much slower than:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;File.open 'dump' do |fp| Marshal.load fp.read end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Because the former uses IO#getc and the latter operates directly on a String.&lt;/p&gt;


	&lt;p&gt;I learned this tonight while helping profile code at a &lt;a href="http://rubyholic.com/groups/show/1"&gt;Seattle.rb&lt;/a&gt; hacking night.&lt;/p&gt;
</description>
      <pubDate>Tue, 02 May 2006 21:52:41 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:b5a67728-6302-480d-9c36-f1360fa4dbca</guid>
      <author>drbrain@segment7.net (Eric Hodel)</author>
      <link>http://blog.segment7.net/articles/2006/05/02/marshal-load-speed</link>
      <category>Hacking</category>
      <category>Ruby</category>
    </item>
    <item>
      <title>"Marshal.load Speed" by Daniel Berger</title>
      <description>&lt;p&gt;That&amp;#8217;s true Nathaniel, but I would think there would be a happier medium using line based reading instead of character based (ick).  I haven&amp;#8217;t looked at the innards of Marshal, though, so maybe there is no other way.&lt;/p&gt;</description>
      <pubDate>Thu, 04 May 2006 07:37:42 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:2337066e-8efb-4a9f-b76b-939710846979</guid>
      <link>http://blog.segment7.net/articles/2006/05/02/marshal-load-speed#comment-233</link>
    </item>
    <item>
      <title>"Marshal.load Speed" by Nathaniel Talbott</title>
      <description>&lt;p&gt;With the &amp;#8220;I&amp;#8217;m sure you know it but I&amp;#8217;ll say it for everyone else&amp;#8217;s benefit&amp;#8221; trade-off that the latter is much less &lt;em&gt;memory&lt;/em&gt; efficient since the whole file must be read in to memory before processing can begin. Of course I&amp;#8217;m usually loading small files, so for me at least that&amp;#8217;s not a big downside &amp;#8211; just something to consider.&lt;/p&gt;


	&lt;p&gt;Thanks for the tip!&lt;/p&gt;</description>
      <pubDate>Wed, 03 May 2006 08:17:27 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:0ec05dad-e504-49cc-a92c-8c062b4a9245</guid>
      <link>http://blog.segment7.net/articles/2006/05/02/marshal-load-speed#comment-232</link>
    </item>
  </channel>
</rss>
