Python asyncore 与普通的旧 C
我正在对 2 个不同的项目进行压力测试:一个是 proxsmtpd - 用 C 编写的 smtp 代理 另一个是 smtp_proxy.py,我使用 asyncore 和 smtpd python 模块在 1 小时内开发了它。
我在重负荷下强调了这两个项目, 发现 proxsmtpd 能够保持 400 个 smtp 会话/秒, 而我的 python 程序每秒只能执行 160 个 smtp 会话。
所以,我的问题是,这是因为 asyncore 存在一些性能限制吗? 或者 C 程序只是更快?或者也许是我,以低效的方式使用 asyncore?
i'm stress testing 2 different projects: one is proxsmtpd - smtp proxy written in C
And the other one, smtp_proxy.py, which i developed under 1 hour, with use of asyncore and smtpd python modules.
I stressed both projects under heavy load,
and found out that proxsmtpd is able to hold 400 smtp sessions / sec,
while my python program, is able to do only 160 smtp sessions /sec.
So, my question is, does it because there are some performance limitations in asyncore,
or C programs are just faster? Or maybe it's me, using asyncore in inefficient way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这是一个合理的假设,即给定一个好 C 版本和一个好 Python 版本,C 版本将更快且更具可扩展性,但就您而言,您可能想要运行分析器并查看您的程序没有像 C 版本那样扩展的原因和位置。也许您可以发现瓶颈并对其进行优化,以从代码中获得更多性能。另外,我对 asyncore 不太了解,但是当人们想要做异步事情时,他们倾向于使用的第一个 Python 库似乎是扭曲的。所以,也许那里有性能改进。
I think it's a fair assumption that given a good C version and a good Python version, the C version will be faster and more scalable but in your case, you might want to run a profiler and see why and where your program is not scaling up as much as the C version. Perhaps you can uncover the tight spots and optimise it to squeeze some more performance out of your code. Also, I don't know much about asyncore but the first Python library people seem to gravitate towards when they want to do async stuff is twisted. So, perhaps there is a performance improvement there.