Hi all,
for a talk I'm about to give, I ran the pybench benchmark with
cython-unstable. I had to fix up the sources a tiny bit (nothing that
impacts the results) and select the benchmarks that actually compile
(mostly due to inner classes being used). It's run like this:
PYTHONPATH=. python2.6 -c 'import pybench; pybench.PyBenchCmdline()' \
--debug -w 1 -n 5 -f results-cython.pybench -t \
'Arithmetic|IfThen|Loops|Dict|Try.*Except|Import|List|Compare|String|Tuple|Unicode'
FWIW, both the Python 2.6.2 interpreter and the Cython generated C modules
were built on the same machine with the same CFLAGS.
The sources I used are here:
http://codespeak.net/lxml/pybench.tar.gz
I attached the results.
I left out the CompareIntegers/Floats/etc. benchmarks as they only compare
numeric literals, which ends up in the C code as, well, a comparison of
literals, so that the C compiler finds a lot of dead code to discard. The
resulting 100% speedup isn't really that informative.
Note that the numbers are for plain Python code without any type
annotations, so a lot of possible optimisations are not even used.
However, the remaining total improvement of almost 33%, and the huge
speedups for control structures (especially loops) and builtin types is
clearly worth a look.
Have fun,
Stefan
-------------------------------------------------------------------------------
PYBENCH 2.0
-------------------------------------------------------------------------------
* using CPython 2.6.2 (r262:71600, Apr 17 2009, 11:29:30) [GCC 4.3.2]
* disabled garbage collection
* system check interval set to maximum: 2147483647
* using timer: time.time
-------------------------------------------------------------------------------
Benchmark: results-cython-selected2.pybench
-------------------------------------------------------------------------------
Rounds: 5
Warp: 1
Timer: time.time
Machine Details:
Platform ID: Linux-2.6.27-14-generic-i686-with-debian-lenny-sid
Processor:
Python:
Implementation: CPython
Executable: /usr/local/bin/python2.6
Version: 2.6.2
Compiler: GCC 4.3.2
Bits: 32bit
Build: Apr 17 2009 11:29:30 (#r262:71600)
Unicode: UCS4
-------------------------------------------------------------------------------
Comparing with: results-py2.6.pybench
-------------------------------------------------------------------------------
Rounds: 5
Warp: 1
Timer: time.time
Machine Details:
Platform ID: Linux-2.6.27-14-generic-i686-with-debian-lenny-sid
Processor:
Python:
Implementation: CPython
Executable: /usr/local/bin/python2.6
Version: 2.6.2
Compiler: GCC 4.3.2
Bits: 32bit
Build: Apr 17 2009 11:29:30 (#r262:71600)
Unicode: UCS4
Test minimum run-time average run-time
this other diff this other diff
-------------------------------------------------------------------------------
CompareInternedStrings: 463ms 1548ms -70.1% 466ms 1552ms -69.9%
CompareStrings: 822ms 1504ms -45.4% 823ms 1510ms -45.5%
CompareUnicode: 777ms 1314ms -40.8% 779ms 1315ms -40.7%
ConcatStrings: 2148ms 2516ms -14.6% 2198ms 2554ms -13.9%
ConcatUnicode: 2378ms 2514ms -5.4% 2384ms 2523ms -5.5%
CreateStringsWithConcat: 1600ms 1801ms -11.2% 1610ms 1805ms -10.8%
CreateUnicodeWithConcat: 1370ms 1590ms -13.8% 1373ms 1646ms -16.6%
DictCreation: 595ms 1057ms -43.7% 596ms 1065ms -44.0%
DictWithFloatKeys: 1619ms 1579ms +2.6% 1647ms 1584ms +4.0%
DictWithIntegerKeys: 735ms 1252ms -41.3% 741ms 1264ms -41.4%
DictWithStringKeys: 472ms 1145ms -58.8% 473ms 1153ms -59.0%
ForLoops: 150ms 1131ms -86.7% 150ms 1140ms -86.8%
IfThenElse: 445ms 1309ms -66.0% 448ms 1314ms -65.9%
ListSlicing: 1211ms 1225ms -1.1% 1213ms 1230ms -1.3%
NestedForLoops: 130ms 1447ms -91.0% 130ms 1458ms -91.1%
SecondImport: 1226ms 1136ms +7.9% 1228ms 1139ms +7.9%
SecondPackageImport: 1282ms 1176ms +9.0% 1286ms 1202ms +7.0%
SecondSubmoduleImport: 1622ms 1554ms +4.4% 1629ms 1619ms +0.6%
SimpleComplexArithmetic: 843ms 1260ms -33.0% 857ms 1268ms -32.4%
SimpleDictManipulation: 896ms 1297ms -30.9% 898ms 1302ms -31.0%
SimpleFloatArithmetic: 512ms 1174ms -56.4% 530ms 1180ms -55.1%
SimpleIntFloatArithmetic: 480ms 1048ms -54.2% 485ms 1048ms -53.8%
SimpleIntegerArithmetic: 471ms 1048ms -55.1% 474ms 1048ms -54.8%
SimpleListManipulation: 422ms 1121ms -62.3% 429ms 1123ms -61.8%
SimpleLongArithmetic: 875ms 1202ms -27.2% 878ms 1206ms -27.2%
SmallLists: 838ms 1330ms -37.0% 840ms 1334ms -37.0%
SmallTuples: 760ms 1323ms -42.5% 765ms 1330ms -42.4%
StringMappings: 1127ms 1247ms -9.6% 1137ms 1252ms -9.2%
StringPredicates: 991ms 1302ms -23.9% 1011ms 1303ms -22.4%
StringSlicing: 981ms 1543ms -36.4% 1107ms 1699ms -34.8%
TryExcept: 159ms 1065ms -85.0% 160ms 1067ms -85.0%
TryRaiseExcept: 85ms 1103ms -92.3% 85ms 1107ms -92.3%
TupleSlicing: 1149ms 1381ms -16.8% 1153ms 1390ms -17.0%
UnicodeMappings: 1519ms 1533ms -0.9% 1526ms 1547ms -1.3%
UnicodePredicates: 938ms 1197ms -21.6% 946ms 1198ms -21.1%
UnicodeProperties: 1025ms 1352ms -24.2% 1026ms 1357ms -24.4%
UnicodeSlicing: 1213ms 1698ms -28.6% 1216ms 1763ms -31.0%
-------------------------------------------------------------------------------
Totals: 34331ms 51023ms -32.7% 34702ms 51592ms -32.7%
(this=results-cython-selected2.pybench, other=results-py2.6.pybench)
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev