<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/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>A View From Above: Tag performance</title>
    <link>http://www.ghostganz.com/blog/articles/tag/performance?tag=performance</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Anders Bengtsson on programming and other things</description>
    <item>
      <title>BigDecimal performance notes</title>
      <description>&lt;p&gt;Notes on &lt;code&gt;java.math.BigDecimal&lt;/code&gt;&amp;#8217;s performance (in Java 1.5):&lt;/p&gt;


	&lt;h4&gt;Sorting&lt;/h4&gt;


	&lt;p&gt;BigDecimal&amp;#8217;s &lt;code&gt;compareTo&lt;/code&gt; method relies on both of the BigDecimals being in the same internal form. Internally BigDecimal uses either a BigInteger or, when possible, a native integer to represent its value. To compare two BigDecimals they&amp;#8217;re both normalized (&amp;#8220;inflated&amp;#8221;) to the BigInteger form. This means that simply sorting a list of BigDecimals can cause memory use to increase. Not what you&amp;#8217;d expect.&lt;/p&gt;


	&lt;h4&gt;Serialization&lt;/h4&gt;


	&lt;p&gt;Serialization of BigDecimal is surprisingly slow. Not only do they inflate their internal representation, just like when comparing, but they also use a lot of &lt;span class="caps"&gt;CPU&lt;/span&gt; for some reason. When serializing large graphs of objects of a lot of different classes, the BigDecimals stood out like a sore thumb in the &lt;span class="caps"&gt;CPU&lt;/span&gt; profile. Dumping them as String representations instead was quicker and didn&amp;#8217;t use as much memory.&lt;/p&gt;</description>
      <pubDate>Wed, 04 Jun 2008 13:47:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:64beba92-165c-4dde-b6ad-f516b6a88789</guid>
      <author>Anders</author>
      <link>http://www.ghostganz.com/blog/articles/2008/06/04/bigdecimal-performance-notes</link>
      <category>Java</category>
      <category>Programming</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
