如何对我选择的 XML 解析器进行基准测试?
我将处理一个巨大的 XML 文件,并且我将使用 XMLReader。以下是三种方法,但我需要知道哪一种最快。我怎么知道这个? Planet.xml 文件位于 http://trash.chregu.tv/planet-big .xml.bz2以防您可能需要它。谢谢你!
I will handle a huge XML file and I will go with XMLReader. Below are three ways to go with, but I need to know which one is the fastest. How can I know this? The planet.xml file is located at http://trash.chregu.tv/planet-big.xml.bz2 in case hat you may need it. Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能需要考虑 PHP 分析扩展:
http://www.php.net/apd
您可以使用 pprofp 检查结果:
http://www.compago.it/php/phpckbk-CHP-21-SECT-3.html
You might want to consider the PHP profiling extension:
http://www.php.net/apd
You can examine the results with pprofp:
http://www.compago.it/php/phpckbk-CHP-21-SECT-3.html
我在 PHP 中使用过的 XML 不多,但如果您要处理一个非常大的文件,那么流式解析器是不错的选择。将整个内容读入内存并构建 DOM 树是相当昂贵的(如果文档太大而无法保存在内存中,甚至可能会失败)。
I haven't worked with XML much in PHP, but if you're dealing with a really large file, a streaming parser is the way to go. Reading the whole thing into memory and building a DOM tree is pretty expensive (and may even fail, if the document's too big to hold in memory).