本文介绍了Python执行速度:笔记本电脑与台式机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个进行简单数据处理的程序:

I am running a program that does simple data processing:

  • 解析文本
  • 填充字典
  • 根据结果数据计算一些函数

该程序仅使用CPU,RAM和HDD:

The program only uses CPU, RAM, and HDD:

  • 从Windows命令行运行
  • 输入/输出到本地硬盘驱动器
  • 屏幕上没有显示或打印任何内容
  • 不联网

同一程序在以下位置运行:

The same program is run on:

  • 台式机:Windows 7,i7-930 CPU超频@ 3.6 GHz(具有匹配的内存速度),Intel X-25M SSD
  • 笔记本电脑:Windows XP,Intel Core2 Duo T9300 @ 2.5GHz,7200 rpm HDD

CPU的频率提高了1.44,HDD的基准得分提高了4倍(Passmark-Disk Mark).我发现该程序在台式机上的运行速度大约是其1.66倍.因此,显然,CPU是瓶颈.

The CPU is 1.44 faster frequency, HDD is 4 times higher benchmark score (Passmark - Disk Mark). I found the program runs just around 1.66 times faster on the desktop. So apparently, the CPU is the bottleneck.

看来,i7 Core与Intel Core2 Duo架构相比仅带来15%的收益(大部分性能提升是由于CPU频率一直保持不变).我可以在代码中做些什么来增加新体系结构的好处?

It seems there's only 15% benefit from the i7 Core vs Intel Core2 Duo architecture (most of the performance boost is due to the straight CPU frequency). Is there anything I can do in the code to increase the benefit of the new architecture?

忘了说我使用ActivePython 3.1.2(如果有的话).

forgot to mention that I use ActivePython 3.1.2 if that matters.

推荐答案

硬件性能的提高在大多数情况下会自动使用户应用受益.恶意的"GIL"意味着您可能无法利用CPython使用多核,除非您设计程序通过各种多处理模块/库来利用.

The increasing performance of hardware brings in most cases automatically results in benefit to user applications. The much maligned "GIL" means that you may not be able to take advantage of multicores with CPython unless you design your program to take advantage via various multiprocessing modules / libraries.

关于SO的讨论在同一篇文章中: python是否支持多处理器/多核编程?

SO discussion on the same : Does python support multiprocessor/multicore programming?

关于python Wiki的解决方案的相关整理: http://wiki.python.org/moin/并行处理

A related collation of solutions on python wiki: http://wiki.python.org/moin/ParallelProcessing

这篇关于Python执行速度:笔记本电脑与台式机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 20:51