Windows 上的 Python 性能

发布于 2024-08-13 14:08:07 字数 209 浏览 4 评论 0原文

Python 在 Windows 上通常比 *nix 机器上慢吗? Python 似乎在我的 Mac OS X 机器上运行得很好,而在我的 Windows Vista 机器上似乎运行得更慢。这些机器的处理能力相似,vista 机器的内存多 1GB。

我在 Mercurial 中特别注意到这一点,但我认为这可能只是 Mercurial 在 Windows 上的打包方式。

Is Python generally slower on Windows vs. a *nix machine? Python seems to blaze on my Mac OS X machine whereas it seems to run slower on my Window's Vista machine. The machines are similar in processing power and the vista machine has 1GBs more memory.

I particularly notice this in Mercurial but I figure this may simply be how Mercurial is packaged on windows.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(6

挖鼻大婶 2024-08-20 14:08:07

我想跟进此事,并发现了一些我认为是“我的答案”的东西。看起来 Windows(vista,这是我注意到的)处理文件的速度不那么快。 tony-p-lee 提到过这一点。

我发现了 Ubuntu vs Vista vs Win7。他们的结果很有趣,就像他们说的,你需要对结果持保留态度。但我认为结果引导我找到原因。我觉得 Python 是间接测试的,在 Windows 上即使不是快一点,也差不多是等价的。请参阅“Richards benchmark”部分。

这是他们的文件传输图表:

图表 - 小文件高清到高清
(来源:tuxradar.com

我认为这特别有助于解决这个问题,因为 Hg 实际上只是一系列文件读取、复制和整体处理。这很可能是导致延迟的原因。

http://www.tuxradar.com/content/基准测试-ubuntu-vs-vista-vs-windows-7

I wanted to follow up on this and I found something that I believe is 'my answer'. It appears that Windows (vista, which is what I notice this on) is not as fast in handling files. This was mentioned by tony-p-lee.

I found this comparisons of Ubuntu vs Vista vs Win7. Their results are interesting and like they say, you need to take the results with a grain of salt. But I think the results lead me to the cause. Python, which I feel was indirectly tested, is about equivalent if not a tad-bit faster on Windows.. See the section "Richards benchmark".

Here is their graph for file transfers:

Graph - small file HD to HD
(source: tuxradar.com)

I think this specifically help address the question because Hg is really just a series of file reads, copies and overall handling. Its likely this is causing the delay.

http://www.tuxradar.com/content/benchmarked-ubuntu-vs-vista-vs-windows-7

浪荡不羁 2024-08-20 14:08:07

这里没有真实的数字,但确实感觉 Windows 平台上的启动时间更慢。我经常在家里的 Ubuntu 和工作的 Windows 7 之间切换,尽管我的工作机器的速度至少是后者的 4 倍,但在 Ubuntu 上启动速度要快一个数量级。

至于运行时性能,对于“安静”的应用程序来说感觉差不多。如果在 Windows 上有任何使用 Tk 的 GUI 操作,它们肯定会更慢。 Windows 上的任何控制台应用程序都比较慢,但这很可能是因为 Windows cmd 渲染速度比 python 运行速度慢。

No real numbers here but it certainly feels like the start up time is slower on Windows platforms. I regularly switch between Ubuntu at home and Windows 7 at work and it's an order of magnitude faster starting up on Ubuntu, despite my work machine being at least 4x the speed.

As for runtime performance, it feels about the same for "quiet" applications. If there are any GUI operations using Tk on Windows, they are definitely slower. Any console applications on windows are slower, but this is most likely due to the Windows cmd rendering being slow more than python running slowly.

所谓喜欢 2024-08-20 14:08:07

也许python更多地依赖于打开的大量文件(导入不同的模块)。

Windows 处理文件打开的效率不如 Linux。

或者也许 Linux 可能有更多依赖于 python 的实用程序,并且 python 脚本/模块更有可能在系统缓存中缓冲。

Maybe the python has more depend on a lot of files open (import different modules).

Windows doesn't handle file open as efficiently as Linux.

Or maybe Linux probably have more utilities depend on python and python scripts/modules are more likely to be buffered in the system cache.

玩心态 2024-08-20 14:08:07

我在 Windows XP 和 7 以及 Macbook 上的 OSX 上本地运行 Python。我发现命令行解释器没有明显的性能差异,wx widget 应用程序运行相同,Django 应用程序的性能也几乎相同。

我在工作中注意到的一件事是卡巴斯基病毒扫描程序往往会降低 python 解释器的速度。 python 提示符需要 3-5 秒才能正确显示,Django 的测试服务器完全加载需要 7-10 秒。正确禁用其主动扫描可将启动时间恢复到 0 秒。

I run Python locally on Windows XP and 7 as well as OSX on my Macbook. I've seen no noticable performance differences in the command line interpreter, wx widget apps run the same, and Django apps also perform virtually identically.

One thing I noticed at work was that the Kaspersky virus scanner tended to slow the python interpreter WAY down. It would take 3-5 seconds for the python prompt to properly appear and 7-10 seconds for Django's test server to fully load. Properly disabling its active scanning brought the start up times back to 0 seconds.

苍景流年 2024-08-20 14:08:07

通过操作系统和网络库,我可以确认 Windows 上的性能较慢,至少对于版本 =< 2.6.

我编写了一个 CLI podcast-fetcher 脚本,它在 Ubuntu 上运行得很好,但在 XP 或 7 上下载任何东西的速度都不会超过 80 kB/s(其中 ~1.6 MB/s 是我通常的最大值)。

我可以部分纠正这是通过调整下载流的缓冲区大小来实现的,但 Windows 上肯定存在主要瓶颈,无论是通过网络还是 IO,这在 Linux 上根本不是问题。

基于此,似乎系统和操作系统接口任务针对 *nix 的优化比针对 Windows 的优化要好。

With the OS and network libraries, I can confirm slower performance on Windows, at least for versions =< 2.6.

I wrote a CLI podcast-fetcher script which ran great on Ubuntu, but then wouldn't download anything faster than about 80 kB/s (where ~1.6 MB/s is my usual max) on either XP or 7.

I could partially correct this by tweaking the buffer size for download streams, but there was definitely a major bottleneck on Windows, either over the network or IO, that simply wasn't a problem on Linux.

Based on this, it seems that system and OS-interfacing tasks are better optimized for *nixes than they are for Windows.

微凉 2024-08-20 14:08:07

有趣的是,我对 Windows 10 x64 机器(诚然低功耗)上的流行 Python 应用程序和同一机器上运行的 Ubuntu 14.04 VM 进行了直接比较。

我没有测试加载速度等,但我只是查看两者之间的处理器使用情况。为了使测试公平,两者都是全新安装,我复制了媒体库的一部分,并在两种情况下应用了相同的配置。每个测试都是独立运行的。

  • 在 Windows 上,Python 使用了我的处理器能力的 20%,它触发系统压缩内存以 40% 的速度运行(这是一台具有 6GB 或 RAM 的旧机器)。
  • 对于 Ubuntu 上的虚拟机(链接到我的 Windows 文件系统),处理器使用率约为 5%,压缩内存降至约 20%。

这是一个巨大的差异。我运行此测试的触发因素是使用 python 的应用程序将我的 CPU 运行到 100% 并且无法运行。我现在已经在虚拟机中运行它 2 周了,我的处理器使用率平均下降到 65-70%。因此,无论是长期还是短期测试,并考虑到运行虚拟机和第二个操作系统的开销,这个 Python 应用程序在 Linux 上的速度都要快得多。我还可以确认 Python 应用程序的响应更好,就像我机器上的其他所有东西一样。

现在这可能是非常特定于应用程序的,但至少很有趣。

PC 是旧的 AMD II X2 X265 处理器、6GB RAM、SSD HD(Python 运行于此,但虚拟机使用常规 5200rpm HD,可用于大量其他内容,包括录制 2 个闭路电视摄像机)。

Interestingly I ran a direct comparison of a popular Python app on a Windows 10 x64 Machine (low powered admittedly) and a Ubuntu 14.04 VM running on the same machine.

I have not tested load speeds etc, but am just looking at processor usage between the two. To make the test fair, both were fresh installs and I duplicated a part of my media library and applied the same config in both scenarios. Each test was run independently.

  • On Windows Python was using 20% of my processor power and it triggered System Compressed Memory to run up at 40% (this is an old machine with 6GB or RAM).
  • With the VM on Ubuntu (linked to my windows file system) the processor usage is about 5% with compressed memory down to about 20%.

This is a huge difference. My trigger for running this test was that the app using python was running my CPU up to 100% and failing to operate. I have now been running it in the VM for 2 weeks and my processor usage is down to 65-70% on average. So both on a long and short term test, and taking into account the overhead of running a VM and second operating system, this Python app is significantly faster on Linux. I can also confirm that the Python app responds better, as does everything else on my machine.

Now this could be very application specific, but it is at minimum interesting.

The PC is an old AMD II X2 X265 Processor, 6GB of RAM, SSD HD (which Python ran from but the VM used a regular 5200rpm HD which gets used for a ton of other stuff including recording of 2 CCTV cameras).

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