<?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>Some reminiscences, some memories &#187; config</title>
	<atom:link href="http://www.mikespook.com/index.php/tag/config/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mikespook.com</link>
	<description>Just another boring day</description>
	<lastBuildDate>Tue, 10 Jan 2012 03:14:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Zend_Db_Adapter 的 charset 的 issue 指派给我了</title>
		<link>http://www.mikespook.com/2007/08/zend_db_adapter-%e7%9a%84-charset-%e7%9a%84-issue-%e6%8c%87%e6%b4%be%e7%bb%99%e6%88%91%e4%ba%86/</link>
		<comments>http://www.mikespook.com/2007/08/zend_db_adapter-%e7%9a%84-charset-%e7%9a%84-issue-%e6%8c%87%e6%b4%be%e7%bb%99%e6%88%91%e4%ba%86/#comments</comments>
		<pubDate>Sat, 04 Aug 2007 03:25:44 +0000</pubDate>
		<dc:creator>mikespook</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[charset]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[Zend_Db_Adapter]]></category>

		<guid isPermaLink="false">http://blog.xxiyy.com/index.php/archives/40</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>
Bill 这个老家伙，这么多天，才指派了 issue 过来。

这个 charset 应该放在 config 的什么部分？

我个人倾向于跟 $config['port'] 一样，直接放在 config 数组中： $config['charset']。实际上之前的修改也是这么做的。

<span class="readmore"><a href="http://www.mikespook.com/2007/08/zend_db_adapter-%e7%9a%84-charset-%e7%9a%84-issue-%e6%8c%87%e6%b4%be%e7%bb%99%e6%88%91%e4%ba%86/" title="Zend_Db_Adapter 的 charset 的 issue 指派给我了">阅读全文——共351字</a></span>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>
<p>Bill 这个老家伙，这么多天，才指派了 issue 过来。</p>
<p>这个 charset 应该放在 config 的什么部分？</p>
<p>我个人倾向于跟 $config['port'] 一样，直接放在 config 数组中： $config['charset']。实际上之前的修改也是这么做的。</p>
<p>但是还有一个选择是放在 $config['options']['charset']。这样肯定更符合老外的胃口，他们很少用 charset 这个东东的。</p>
<p>Bill 发邮件说他想放到 $config['driver-options']['charset']，我是严重的不同意。这个肯定不是数据库特性的东西，而应该是跟 port 一样是每个数据库不同，但是每个都可以设置的东西。</p>
<p>恩，考虑考虑先～～反正无论如何，我不同意放到 driver-options 里去设置 charset。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikespook.com/2007/08/zend_db_adapter-%e7%9a%84-charset-%e7%9a%84-issue-%e6%8c%87%e6%b4%be%e7%bb%99%e6%88%91%e4%ba%86/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zend_Config_Ini 与 Zend_Config_Xml 在性能上的比较</title>
		<link>http://www.mikespook.com/2007/07/zend_config_ini-%e4%b8%8e-zend_config_xml-%e5%9c%a8%e6%80%a7%e8%83%bd%e4%b8%8a%e7%9a%84%e6%af%94%e8%be%83/</link>
		<comments>http://www.mikespook.com/2007/07/zend_config_ini-%e4%b8%8e-zend_config_xml-%e5%9c%a8%e6%80%a7%e8%83%bd%e4%b8%8a%e7%9a%84%e6%af%94%e8%be%83/#comments</comments>
		<pubDate>Thu, 26 Jul 2007 02:16:16 +0000</pubDate>
		<dc:creator>mikespook</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[ini]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://blog.xxiyy.com/index.php/archives/36</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>
在分析 Zend_Config 的代码的时候，感觉 Ini.php 和 Xml.php 中代码差异非常大。那么性能上是否有一个确定的优劣？于是做了以下比较和分析。

先看一下两个类在加载配置文件上的差异：

Ini 使用的是 parse_ini_file 这个内置函数。在我使用 xdebug 中记录的性能测试中，这个内置函数的运行时间可以忽略不计，可以说执行速度相当快。

<span class="readmore"><a href="http://www.mikespook.com/2007/07/zend_config_ini-%e4%b8%8e-zend_config_xml-%e5%9c%a8%e6%80%a7%e8%83%bd%e4%b8%8a%e7%9a%84%e6%af%94%e8%be%83/" title="Zend_Config_Ini 与 Zend_Config_Xml 在性能上的比较">阅读全文——共920字</a></span>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>
<p>在分析 Zend_Config 的代码的时候，感觉 Ini.php 和 Xml.php 中代码差异非常大。那么性能上是否有一个确定的优劣？于是做了以下比较和分析。<span id="more-36"></span></p>
<p>先看一下两个类在加载配置文件上的差异：</p>
<p>Ini 使用的是 parse_ini_file 这个内置函数。在我使用 xdebug 中记录的性能测试中，这个内置函数的运行时间可以忽略不计，可以说执行速度相当快。</p>
<p>Xml 使用的是 simplexml_load_file 这个内置函数，由于 xml 本身的众所周知的原因，这个函数的执行非常耗时，平均大约需要 0.3 ms。</p>
<p>这么乍一看，好像是 Ini 的性能更加优秀一些。且慢，请继续看。</p>
<p>Ini 虽然在加载配置文件上非常占优势，但是由于 Ini 文件本身不是分层记录。而 Zend Framework 利用分隔符（默认是&ldquo;.&rdquo;）定义了 Ini 文件的分层关系。这就是说在配置文件加载后，仍然需要对加载的数组进行解析。Zend Framework 中使用的是解析后迭代 Zend_Config 类的构造函数的方法。逐个解析读取的数组元素，然后使用 Zend_Config::__construct() 进行迭代处理。最后构造出完整的配置数据对象。</p>
<p>Xml 则容易许多，由于 simplexml_load_file 加载后就是完整的有层次关系的数组。这样在迭代 Zend_Config::__construct() 构造配置数据对象时就省略的复杂的解析层次关系这一步。虽然 simplexml_load_file 自身执行时间很长，但是它已经解决了后面的许多工作。</p>
<p>所以结论呢，Xml 性能上更优秀一些？</p>
<p>错！</p>
<p>对于只有一层的配置文件，由于没有复杂的层级处理 Ini 显然更加快速。</p>
<p>而对于复杂的、有众多继承关系的配置文件来说 Xml 是不二选择。</p>
<p>不过我想，对于多数应用，为了更好的管理配置文件，恐怕都使用了大量的层级来区分不同的配置模块。比如在 ninny 项目中，数据库、缓存、会话、模块等等都不是单层次的配置。所以我将其改进为 Xml 配置文件，以提升那 7 ms 的性能。*_*!</p>
<p>本想针对 Zend_Config 做一次全面的行级代码分析，不过第一没时间，第二代码量太大，实在麻烦，所有就用本文做个对 Zend_Config 的了结吧。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikespook.com/2007/07/zend_config_ini-%e4%b8%8e-zend_config_xml-%e5%9c%a8%e6%80%a7%e8%83%bd%e4%b8%8a%e7%9a%84%e6%af%94%e8%be%83/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

