STINNER Victor added the comment:

My results of the benchmark on Linux 3.9, first with a loop calling 
fileobj.read(8192) ("read"), then with the "for line in fileobj: pass" 
("readline").

$ python2.7 bench_socket_read.py
TCP  mode, makefile method. 1775085.8 lines per second (1692.9 MB/s). Delay is 
0.56 seconds
TCP  mode,   fdopen method. 2767162.2 lines per second (2639.0 MB/s). Delay is 
0.36 seconds
UNIX mode, makefile method. 5238015.2 lines per second (4995.4 MB/s). Delay is 
0.19 seconds
UNIX mode,   fdopen method. 6218906.2 lines per second (5930.8 MB/s). Delay is 
0.16 seconds

$ python3.4 bench_socket_read.py
TCP  mode, makefile method. 1403075.1 lines per second (1338.1 MB/s). Delay is 
0.71 seconds
TCP  mode,   fdopen method. 2324254.2 lines per second (2216.6 MB/s). Delay is 
0.43 seconds
UNIX mode, makefile method. 1770625.0 lines per second (1688.6 MB/s). Delay is 
0.56 seconds
UNIX mode,   fdopen method. 4953624.6 lines per second (4724.1 MB/s). Delay is 
0.20 seconds

$ python2.7 bench_socket_readline.py
TCP  mode, makefile method. 246268.2 lines per second (234.9 MB/s). Delay is 
4.06 seconds
TCP  mode,   fdopen method. 1980998.2 lines per second (1889.2 MB/s). Delay is 
0.50 seconds
UNIX mode, makefile method. 3378778.4 lines per second (3222.3 MB/s). Delay is 
0.30 seconds
UNIX mode,   fdopen method. 3271267.0 lines per second (3119.7 MB/s). Delay is 
0.31 seconds

$ python3.4 bench_socket_readline.py
TCP  mode, makefile method. 826646.7 lines per second (788.4 MB/s). Delay is 
1.21 seconds
TCP  mode,   fdopen method. 1664917.8 lines per second (1587.8 MB/s). Delay is 
0.60 seconds
UNIX mode, makefile method. 942409.0 lines per second (898.8 MB/s). Delay is 
1.06 seconds
UNIX mode,   fdopen method. 2619285.2 lines per second (2497.9 MB/s). Delay is 
0.38 seconds

The results of the "read" benchmark for "UNIX mode, makefile method" case are 
very different on Python 2.7 (call read()) and Python 3.4 (call recv()): 4995.4 
MB/s vs 1688.6 MB/s (2.95x slower).

Readline on TCP is much faster on Python 3.4 than 2.7: 788.4 MB/s vs 234.9 MB/s 
(3.4x faster). I don't know why, but I don't want to investigate (it is not a 
regression) :-)

The slowdown on other readline tests are less interesting: Python 3.4 is 16% 
slower for "TCP  mode, fdopen method" and 20% slower for "UNIX mode, fdopen 
method".

It would be interesting to have the same benchmark implemented in C to compare 
"raw" performances, so it would be possible to measure the overhead of Python.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18329>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to