On this page... (hide)
1.�前言
2.�实验方案
3.�硬件平台
4.�软件平台
5.�实验过程及结果
5.1�Stackless Python的实验
结果
5.2�使用thread模块的实验结果
5.3�使用threading模块配合
Queue模块的实验结果
5.4�使用processing模块配合
Queue模块的实验结果
5.5�比较结果
6.�实验代码
6.1�ring_no_io_slp.py
6.2�ring_no_io_thread.py
6.3�ring_no_io_queue.py
6.4�ring_no_io_proc.py
1.� 前言
偶然看到Erlang vs. Stackless python: a
first benchmark,对Erlang和Stackless
Python的并发处理性能进行了实验比较,基本结论认
为二者有比较相近的性能。我看完产生的问题
是,Stackless Python与Python的其他并发实现机
制性能又会有多大区别呢,比如线程和进程。因此我采
用与这篇文章相同的办法来对Stackless Python、
普通Python的thread模块、普通Python的
threading模块、普通Python的processing模块这
四种并发实现方案进行了性能实验,并将实验过程和基
本结果记录在这里。
2.� 实验方案
实验方案与Erlang vs. Stackless python: a
first benchmark是相同的,用每种方案分别给出如下问题的实现,记录完成整个处理过程
的总时间来作为评判性能的依据:
由n个节点组成一个环状网络,在上面传送共m个消息。1.
将每个消息(共m个),逐个发送给1号节点。2.
第1到n-1号节点在接收到消息后,都转发给下一号节点。3.
第n号节点每次收到消息后,不再继续转发。4.
当m个消息都从1号逐个到达第n号节点时,认为全部处理结束。5.
3.� 硬件平台
Macbook Pro 3,1上的Vmware Fusion 1.0虚拟机中,注意这里给虚拟机只启用了cpu的单
个核心:
原始Cpu:Core 2 Duo,2.4 GHz,2核心,4 MB L2 缓存,总线速度800 MHz
分配给虚拟机的内存:796M
4.� 软件平台