<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jorge Alegre Blog &#187; python</title>
	<atom:link href="http://www.jorgealegre.com/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jorgealegre.com</link>
	<description>Internet Startups, Technology, My Music and Me</description>
	<lastBuildDate>Sat, 19 Jun 2010 09:04:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Python Faster Than Java, At Least For BerkeleyDB</title>
		<link>http://www.jorgealegre.com/2010/02/python-faster-than-java-at-least-for-berkeleydb/</link>
		<comments>http://www.jorgealegre.com/2010/02/python-faster-than-java-at-least-for-berkeleydb/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 09:05:14 +0000</pubDate>
		<dc:creator>Jorge Alegre</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[berkeleydb]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.jorgealegre.com/?p=263</guid>
		<description><![CDATA[
			
				
			
		
I tested new Oracle Java edition for Berkeley DB and for my tests the word that best describes the product is FAIL. The conslussion more or less is that Oracle screwed Berkeley software. They have no HASH, only BTREES, many functionality of BerkeleyDB has been removed, etc&#8230; They say is BerkeleyDB with Java flavour, they [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jorgealegre.com%2F2010%2F02%2Fpython-faster-than-java-at-least-for-berkeleydb%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jorgealegre.com%2F2010%2F02%2Fpython-faster-than-java-at-least-for-berkeleydb%2F&amp;source=jalegre&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I tested new Oracle Java edition for Berkeley DB and for my tests the word that best describes the product is FAIL. The conslussion more or less is that Oracle screwed Berkeley software. They have no HASH, only BTREES, many functionality of BerkeleyDB has been removed, etc&#8230; They say is BerkeleyDB with Java flavour, they have a weird sense of java humor then.</p>
<p>I was expecting factor of 5X as many blogs suggested that on real applications we have this improvement. And since BeerkeleyDB for me has a lot of memory use and processing as well I was expecting at least 2X factor. I got a 2X factor but on the contrary.</p>
<p><strong>Results</strong></p>
<p>I did test for creating a table of 1 million rows with 128MB memory Cache.</p>
<table>
<tbody>
<tr>
<td>Language</td>
<td>Time</td>
</tr>
<tr>
<td><strong>Python</strong></td>
<td>12 sec</td>
</tr>
<tr>
<td><strong>Java</strong></td>
<td>28 sec</td>
</tr>
</tbody>
</table>
<p><span id="more-263"></span></p>
<p>So the refactoring of OctopusDbm, if any, will go through C++ inside Linux. I downloaded the Linux Tools for Eclipse and will start playing with those when I have some time.</p>
<p>It seems that Python with C modules work great.</p>
<p>[Update Feb 22 2010]</p>
<p>The tests were performed 5 times and get the average, plus:</p>
<ul>
<li>BerkeleyDB.4.7</li>
<li>bsddb3-4.7.2 (Python API)</li>
<li>Linux SuSE 10.1 Pentium 4 Hyperthreads</li>
<li>Kernel 2.6.16</li>
<li>Sun Java 5</li>
</ul>
<p>And here is the code used:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p263code2'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2632"><td class="code" id="p263code2"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Testing for BerkeleyDB
 */</span>
<span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">test</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.File</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Date</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sleepycat.je.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @author Jorge Alegre
 *
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BerkeleyDB <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> HOME <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/index/test/&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">long</span> CACHE_SIZE <span style="color: #339933;">=</span> <span style="color: #cc66cc;">128000000</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a> MAX <span style="color: #339933;">=</span> <span style="color: #cc66cc;">50000</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * @param args
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</span>
&nbsp;
		EnvironmentConfig envConfig <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> EnvironmentConfig<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		envConfig.<span style="color: #006633;">setAllowCreate</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		envConfig.<span style="color: #006633;">setCacheSize</span><span style="color: #009900;">&#40;</span>CACHE_SIZE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aenvironment+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Environment</span></a> env <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aenvironment+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Environment</span></a><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">File</span></a><span style="color: #009900;">&#40;</span>HOME<span style="color: #009900;">&#41;</span>, envConfig<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Data: &quot;</span> <span style="color: #339933;">+</span> envConfig.<span style="color: #006633;">getCachePercent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">+</span> envConfig.<span style="color: #006633;">getCacheSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		DatabaseConfig dbConfig <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DatabaseConfig<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		dbConfig.<span style="color: #006633;">setAllowCreate</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">long</span> t_1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adate+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Date</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>t_1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		Database db <span style="color: #339933;">=</span> env.<span style="color: #006633;">openDatabase</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;testing&quot;</span>, dbConfig<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		DatabaseEntry key <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DatabaseEntry<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		DatabaseEntry data <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DatabaseEntry<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> sData <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&quot;</span><span style="color: #339933;">;</span>
		data.<span style="color: #006633;">setData</span><span style="color: #009900;">&#40;</span>sData.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a> i<span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i</pre></td></tr></table></div>

<p align="left"><a class="tt" href="http://twitter.com/home/?status=Python+Faster+Than+Java%2C+At+Least+For+BerkeleyDB+http://www.jorgealegre.com/?p=263" title="Post to Twitter"><img class="nothumb" src="http://www.jorgealegre.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Python+Faster+Than+Java%2C+At+Least+For+BerkeleyDB+http://www.jorgealegre.com/?p=263" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://plurk.com/?status=Python+Faster+Than+Java%2C+At+Least+For+BerkeleyDB+http://www.jorgealegre.com/?p=263" title="Post to Plurk"><img class="nothumb" src="http://www.jorgealegre.com/wp-content/plugins/tweet-this/icons/tt-plurk.png" alt="Post to Plurk" /></a> <a class="tt" href="http://plurk.com/?status=Python+Faster+Than+Java%2C+At+Least+For+BerkeleyDB+http://www.jorgealegre.com/?p=263" title="Post to Plurk">Plurk This Post</a> <a class="tt" href="http://digg.com/submit?url=http://www.jorgealegre.com/2010/02/python-faster-than-java-at-least-for-berkeleydb/&amp;title=Python+Faster+Than+Java%2C+At+Least+For+BerkeleyDB" title="Post to Digg"><img class="nothumb" src="http://www.jorgealegre.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.jorgealegre.com/2010/02/python-faster-than-java-at-least-for-berkeleydb/&amp;title=Python+Faster+Than+Java%2C+At+Least+For+BerkeleyDB" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://ping.fm/ref/?method=microblog&amp;title=Python+Faster+Than+Java%2C+At+Least+For+BerkeleyDB&amp;link=http://www.jorgealegre.com/2010/02/python-faster-than-java-at-least-for-berkeleydb/" title="Post to Ping.fm"><img class="nothumb" src="http://www.jorgealegre.com/wp-content/plugins/tweet-this/icons/tt-ping.png" alt="Post to Ping.fm" /></a> <a class="tt" href="http://ping.fm/ref/?method=microblog&amp;title=Python+Faster+Than+Java%2C+At+Least+For+BerkeleyDB&amp;link=http://www.jorgealegre.com/2010/02/python-faster-than-java-at-least-for-berkeleydb/" title="Post to Ping.fm">Ping This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.jorgealegre.com/2010/02/python-faster-than-java-at-least-for-berkeleydb/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
