libevent和epoll,哪个效率更高?
我认为这是最好的两个事件处理库。
这两个都有很多用户,但是哪个更好呢?
I think these are the two event-dealing libraries among the best.
These two both have many users,but which is better?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
epoll是Linux提供的。 libevent 构建在 epoll 之上。
如果您知道自己在做什么,那么单独使用 epoll可能会更高效。
epoll is offered by Linux. libevent is built on top of epoll.
Using epoll alone may thus be more efficient, if you know what you're doing.
正如 blais 提到的,libevent 在内部使用 epoll。 Libev(http://software.schmorp.de/pkg/libev.html)也是一个不错的选择(我觉得它比libevent更好,但这只是我的看法)。就我而言,我在一些项目中直接使用了epoll,在其他项目中使用了libev。我喜欢 libev,因为它还提供计时器、信号、周期性计时器(类似 cron)和统计观察程序。
那么,哪个更好呢?如果您想查看一些套接字描述符,那么 epoll 可能就是您所需要的。如果您正在编写多线程应用程序,那么 libevent/libev 可能是更好的选择。我认为您不会看到 epoll 和 libevent/libev 之间有明显的速度差异。
As mentioned by
blais
, libevent uses epoll internally. Libev (http://software.schmorp.de/pkg/libev.html) is also a good choice (I feel it is better than libevent, but that is just me). As for me, I've used epoll directly in some projects and libev in other projects. I like libev because it also provides timers, signals, periodic timers (cron-like), and stat watchers.So, which is better? If you want to watch a few socket descriptors then epoll is probably all you need. If you are writing a multi-threaded application then libevent/libev would probably be a better way to go. I don't think you'll see an appreciable speed difference between epoll and libevent/libev.