Hi,
I got most of pybench running (as shipped with Python 2.5.1), just had to
rename the .py files to .pyx (except Setup.py) and fix some "*" imports in the
configuration, Cython does not allow that.
Benchmark suites that run:
- Arithmetic
- Constructs
- Lists
- Tuples
- Dict
- Exceptions
- Imports
- Strings
- Numbers
- Unicode
Benchmark suites that do not run:
- Calls
- Lookups
- Instances
- NewInstances
The main problem is that they define classes and functions dynamically, which
is not currently supported by Cython.
The attached text file compares the results of a stock Python 2.5.1 from
Ubuntu Gutsy to a Cython compiled version of the benchmarks. Positive
differences mean that Python is slower than Cython. (I couldn't manage to get
the opposite comparison running due to pickle problems).
The end result is that Cython is almost 1/3 faster than the Python interpreter
for plain Python code. Especially control structures like if/else and loops
gain a lot from compilation, even for plain Python loops.
BIG FAT WARNING: Please do not overrate these numbers, this is an unfair
comparison between an interpreter and a compiler that do not even understand
the same language. Also, I didn't compile Python myself, so the compiler
optimisations differ between the two. However, I did not alter the benchmarks
themselves in any way, so all benchmark functions use exactly the same Python
source code in both runs.
The "0ms" that Cython gives you in a couple of tests are actually real. They
mean that the timings were not measurable compared to the overhead of the
benchmark call itself, which is credible for an empty try-except, for example,
or the comparison of numbers.
Have fun,
Stefan
************************************************************************
**This file compares Python 2.5.1 (this) with Cython 0.9.6.12 (other) **
************************************************************************
-------------------------------------------------------------------------------
PYBENCH 2.0
-------------------------------------------------------------------------------
* using Python 2.5.1
* disabled garbage collection
* system check interval set to maximum: 2147483647
* using timer: time.time
Calibrating tests. Please wait...
Running 10 round(s) of the suite at warp factor 10:
* Round 1 done in 6.541 seconds.
* Round 2 done in 6.499 seconds.
* Round 3 done in 6.634 seconds.
* Round 4 done in 6.501 seconds.
* Round 5 done in 6.558 seconds.
* Round 6 done in 6.581 seconds.
* Round 7 done in 6.521 seconds.
* Round 8 done in 6.567 seconds.
* Round 9 done in 6.503 seconds.
* Round 10 done in 6.502 seconds.
-------------------------------------------------------------------------------
Benchmark: 2008-03-05 17:01:02
-------------------------------------------------------------------------------
Rounds: 10
Warp: 10
Timer: time.time
Machine Details:
Platform ID: Linux-2.6.22-14-generic-i686-with-debian-lenny-sid
Processor:
Python:
Executable: /usr/bin/python
Version: 2.5.1
Compiler: GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
Bits: 32bit
Build: Oct 5 2007 13:36:32 (#r251:54863)
Unicode: UCS4
-------------------------------------------------------------------------------
Comparing with: ../cybench/cybench.log
-------------------------------------------------------------------------------
Rounds: 10
Warp: 10
Timer: time.time
Machine Details:
Platform ID: Linux-2.6.22-14-generic-i686-with-debian-lenny-sid
Processor:
Python:
Executable: /usr/bin/python
Version: 2.5.1
Compiler: GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
Bits: 32bit
Build: Oct 5 2007 13:36:32 (#r251:54863)
Unicode: UCS4
Test minimum run-time average run-time
this other diff this other diff
-------------------------------------------------------------------------------
CompareFloats: 160ms 0ms +7486272.6% 161ms 0ms
+3534624.7%
CompareFloatsIntegers: 155ms 0ms +37093705.7% 155ms 0ms
+6358029.8%
CompareIntegers: 152ms 0ms +32709538.5% 152ms 0ms
+3928831.4%
CompareInternedStrings: 162ms 50ms +223.3% 168ms 51ms +226.4%
CompareLongs: 125ms 601ms -79.1% 126ms 603ms -79.2%
CompareStrings: 164ms 87ms +89.3% 164ms 90ms +83.0%
CompareUnicode: 165ms 107ms +54.6% 166ms 108ms +54.3%
ConcatStrings: 257ms 224ms +14.9% 279ms 243ms +15.1%
ConcatUnicode: 244ms 223ms +9.4% 245ms 224ms +9.6%
CreateNewInstances: 141ms 0ms n/a 142ms 0ms n/a
CreateStringsWithConcat: 189ms 153ms +23.1% 189ms 154ms +22.9%
CreateUnicodeWithConcat: 169ms 142ms +19.0% 172ms 146ms +17.9%
DictCreation: 137ms 63ms +116.3% 138ms 64ms +116.9%
DictWithFloatKeys: 180ms 190ms -5.4% 180ms 193ms -6.4%
DictWithIntegerKeys: 144ms 65ms +120.1% 145ms 66ms +119.3%
DictWithStringKeys: 142ms 51ms +180.1% 142ms 51ms +180.4%
ForLoops: 131ms 22ms +501.1% 132ms 22ms +501.9%
IfThenElse: 139ms 47ms +198.0% 139ms 47ms +197.2%
ListSlicing: 123ms 121ms +1.7% 123ms 121ms +1.5%
NestedForLoops: 154ms 17ms +832.3% 156ms 17ms +843.6%
SecondImport: 136ms 159ms -14.7% 137ms 161ms -15.0%
SecondPackageImport: 141ms 166ms -15.6% 142ms 168ms -15.5%
SecondSubmoduleImport: 174ms 199ms -12.9% 175ms 202ms -13.5%
SimpleComplexArithmetic: 168ms 139ms +20.7% 168ms 139ms +20.8%
SimpleDictManipulation: 150ms 85ms +76.6% 150ms 85ms +75.7%
SimpleFloatArithmetic: 180ms 85ms +112.5% 192ms 86ms +123.4%
SimpleIntFloatArithmetic: 134ms 52ms +157.0% 134ms 52ms +156.7%
SimpleIntegerArithmetic: 134ms 51ms +162.7% 134ms 51ms +162.5%
SimpleListManipulation: 137ms 37ms +271.2% 137ms 37ms +268.5%
SimpleLongArithmetic: 142ms 107ms +32.3% 142ms 108ms +31.6%
SmallLists: 148ms 78ms +89.2% 149ms 79ms +89.1%
SmallTuples: 142ms 75ms +88.0% 143ms 76ms +87.7%
StringMappings: 143ms 124ms +15.1% 144ms 126ms +14.6%
StringPredicates: 169ms 116ms +45.8% 169ms 119ms +42.3%
StringSlicing: 153ms 94ms +62.8% 157ms 99ms +58.3%
TryExcept: 122ms 0ms +10754178.9% 122ms 0ms
+2514522.4%
TryRaiseExcept: 125ms 81ms +53.6% 125ms 83ms +51.2%
TupleSlicing: 144ms 116ms +23.5% 144ms 117ms +23.6%
UnicodeMappings: 142ms 140ms +1.8% 142ms 141ms +1.1%
UnicodePredicates: 146ms 108ms +35.8% 146ms 109ms +33.8%
UnicodeProperties: 134ms 93ms +43.9% 134ms 93ms +43.9%
UnicodeSlicing: 176ms 131ms +34.4% 178ms 135ms +31.8%
-------------------------------------------------------------------------------
Totals: 6468ms 4398ms n/a 6541ms 4464ms n/a
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev