<?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>Bit Matrix &#187; environment</title>
	<atom:link href="http://blog.bit-matrix.com/tag/environment/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bit-matrix.com</link>
	<description>Tech. Code. Linux. MySQL. Ones. Zeroes.</description>
	<lastBuildDate>Tue, 31 Aug 2010 01:10:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How green is your code?</title>
		<link>http://blog.bit-matrix.com/2009/01/20/how-green-is-your-code/</link>
		<comments>http://blog.bit-matrix.com/2009/01/20/how-green-is-your-code/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 07:08:59 +0000</pubDate>
		<dc:creator>Bit Matrix</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[The Future]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blog.bit-matrix.com/?p=35</guid>
		<description><![CDATA[Is your code fast and efficient? Is your nasty for-loop killing penguins somewhere and You don&#8217;t even know about it? We all hacked and brute-forced through a problem at one time or another &#8211; it is inevitable. How much CO2 will your hack release into the atmosphere? Writing power-inefficient code is like driving a fuel-inefficient [...]]]></description>
			<content:encoded><![CDATA[<p>Is your code fast and efficient? Is your nasty for-loop killing penguins somewhere and You don&#8217;t even know about it? We all hacked and brute-forced through a problem at one time or another &#8211; it is inevitable. How much CO2 will your hack release into the atmosphere? Writing power-inefficient code is like driving a fuel-inefficient car &#8211; we&#8217;ve all done it but it&#8217;s just not cool anymore. With <strong><span style="color: #008000;">green</span></strong> finally becoming the buzz-word everywhere, it is time to take a look at a few numbers surrounding the environmental cost of bad code.</p>
<p><span id="more-35"></span></p>
<p>The issue at hand is the amount of power (as in electricity) that your code will consume when running on a large number of users&#8217; computers (since you write awesomely popular software) or over a long period of time (if your software will be in use for years).</p>
<h4>Hacks. Free(-as-in-beer)?</h4>
<p>Suppose you hacked together a quick Flash widget to go on the front page of your up-and-coming website. Your code is nasty and the widget takes up almost all CPU power on a single core but you have no time to fix it and release it as-is.</p>
<p>Lets run some very basic numbers. A normal user might spend 10 seconds viewing your front page before navigating to another page without the widget. Lets also say that a typical Intel Core 2 CPU will consume about <a href="http://en.wikipedia.org/wiki/CPU_power_dissipation">33W</a> when operating one of its cores at 100% load because of your crappy code. For those 10 seconds on the site, your widget has consumed 33W x 10s / 3600 s/h = 0.092 kW·h.</p>
<p>Let us now assume that you site got mildly popular and received a million visitors over the course of a year, each of which spent only 10 seconds on pages containing the widget. Now your widget has consumed about 92,000 kW·h, or 92 MW·h.</p>
<h4>Garbage In &#8211; Carbon Out</h4>
<p>The average household in the United States uses about <a href="http://tonto.eia.doe.gov/ask/electricity_faqs.asp#electricity_use_home">11,000 kW·h</a> (11 MW·h) of electricity, each year. <strong>Congratulations! Your inefficient code has used up enough electricity to power almost 8 homes for a full year</strong>!</p>
<p>If you live in the United States, <a href="http://en.wikipedia.org/wiki/File:Sources_of_electricity_in_the_USA_2006.png">half of this electricity is likely to come from coal</a>. Coal has en energy density of about <a href="http://en.wikipedia.org/wiki/Coal#Energy_density">2.0 kg / kW·h</a> meaning that the amount of coal burned to power your inefficient code is 0.5 * 92,000 kW·h / (2.0 kg / kW·h) = 92,000 kg = 92t. Yes, that is <strong>92 tons of coal!</strong></p>
<p>Given that producing energy from coal also releases CO2 at a rate of about <a href="http://en.wikipedia.org/wiki/Coal#Relative_carbon_cost">0.950 kg / (kW·h)</a>, your code will have resulted in <strong>87.4 tons of CO2</strong>.</p>
<p>These numbers seem quite depressing. What if your widget ends up on the front page of a big site with tens or hundreds of millions of visitors a year? How much environmental destruction can one nested for loop cause? How many dead penguins will you be responsible for? Gasp!</p>
<h4>Save The Planet?</h4>
<p>But let&#8217;s be realistic, code will always consume power and you can only do so much to reduce that. Some applications will have a net benefit of reducing energy consumption by making people more productive and efficient with their time and energy (your punch-the-monkey widget might or might not be one of those).</p>
<p>The point of the matter is that, even when programming, one can consider the environment. If that consideration provides you with the impetus to sit down and properly re-write a power-hungry piece of code then you have made a real physical change in the world. And now, you can put a number on it.</p>
<p>Safe the CPU cycles &#8211; save the world. <img src='http://blog.bit-matrix.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bit-matrix.com/2009/01/20/how-green-is-your-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
