libxml2与expat在XMPP服务器中的比较

huangapple go评论95阅读模式
英文:

libxml2 vs expat for an XMPP server

问题

我正在尝试从头开始创建一个XMPP库(以及稍后的服务器)Go(尽管语言本身并不重要),以此来学习有关XMPP协议和服务器软件开发的知识。

正如你们许多人所知,XMPP是一种基于XML的消息传递协议,它依赖于大量短而频繁的XML流。我认为对于这种应用程序,基于事件的XML解析器应该更好,因为我不需要DOM和其他一些东西(如果我错了,请纠正我)。请记住,这个库是为服务器而设计的,因此可能会同时运行多个实例;

在这种用例中,libxml2和expat两者哪个性能和内存使用更好?

英文:

I'm trying to create an XMPP library (and later a server) from scratch in Go (although the language itself is irrelevant) as a means to learn what I can about the XMPP protocol and server software development in general.

As many of you know, XMPP is messaging protocol based on XML that depends on an enormous amount of short but frequent XML streams. I'm thinking that for such applications an event based XML parser should be better because I won't need DOM and all that (correct me if I'm wrong). Please keep in mind that this library is intended for servers so there might be many instances run at once;

Which one of the two has better performance and memory usage for that use case, libxml2 or expat?

答案1

得分: 12

有一个完整的项目专门回答XML性能问题,叫做XML Benchmark

简而言之,我认为使用libxml2是一个不错的选择,但我还有其他考虑因素,比如平台可用性。话虽如此,根据最新的数据,它通常比expat更快,尽管在整体方案中差距不大。

是的,你应该使用SAX解析器,而不是DOM解析器。

英文:

There is a whole project devoted to answering the question of XML performance called XML Benchmark.

The short answer, in my opinion, is to use libxml2, but I have other considerations beyond pure performance, such as platform availability. That said, it is generally faster than expat according to the latest numbers, though it's fairly close in the great scheme of things.

And yes, you want to use the SAX parser, not the DOM parser.

huangapple
  • 本文由 发表于 2010年9月15日 10:05:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/3714184.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定