Python asyncore 与普通的旧 C

发布于 2024-08-16 19:01:57 字数 294 浏览 4 评论 0原文

我正在对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

許願樹丅啲祈禱 2024-08-23 19:01:57

我认为这是一个合理的假设,即给定一个 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文