最近在准备一个新项目,用python做后台。在考虑使用Python2.6开发,不过有点担心效率问题。搜集了一下这方面的信息,有需要的同学可以参考。
首先在google中搜索"python benchmark",找到一篇资料,说是python26>python25>python24,加上psyco大概有十倍的效率提升。(具体link找不到了,汗)
然后自己测试了一下,使用pybench([url]http://svn.python.org/projects/python/trunk/Tools/pybench[/url]),结果如下:
python 2.6 比python2.4 快了大概20%
python 2.5 的执行效率和python2.4基本上差不多 大概1%-2%的提升
具体数据见附件
本来还想测试加上psyco后的效率,暂时还没弄好怎么用,晚点再说
不过可以肯定的一点是,可以放心在项目中用python26了
E:\stduy\vituallife\doc\spring\python\benchmark\pybench\svn.python.org\projects\python\trunk\Tools\pybench>d:\Python26\python.exe pybench.py -s p24.pybench -c p26.pybench
-------------------------------------------------------------------------------
PYBENCH 2.0
-------------------------------------------------------------------------------
* using CPython 2.6.2c1 (r262c1:71369, Apr 7 2009, 18:44:00) [MSC v.1500 32 bit (Intel)]
* disabled garbage collection
* system check interval set to maximum: 2147483647
* using timer: time.clock
-------------------------------------------------------------------------------
Benchmark: p24.pybench
-------------------------------------------------------------------------------
Rounds: 10
Warp: 10
Timer: time.clock
Machine Details:
Platform ID: Windows-32bit
Processor:
Python:
Implementation: n/a
Executable: d:\Python24\python.exe
Version: 2.4.4
Compiler: MSC v.1310 32 bit (Intel)
Bits: 32bit
Build: Oct 18 2006 08:34:43 (#71)
Unicode: UCS2
-------------------------------------------------------------------------------
Comparing with: p26.pybench
-------------------------------------------------------------------------------
Rounds: 10
Warp: 10
Timer: time.clock
Machine Details:
Platform ID: Windows-XP-5.1.2600-SP2
Processor: x86 Family 15 Model 4 Stepping 1, GenuineIntel
Python:
Implementation: CPython
Executable: d:\Python26\python.exe
Version: 2.6.2c1
Compiler: MSC v.1500 32 bit (Intel)
Bits: 32bit
Build: Apr 7 2009 18:44:00 (#r262c1:71369)
Unicode: UCS2
Test minimum run-time average run-time
this other diff this other diff
-------------------------------------------------------------------------------
BuiltinFunctionCalls: 212ms 170ms +24.8% 219ms 175ms +25.1%
BuiltinMethodLookup: 210ms 179ms +17.6% 219ms 183ms +19.4%
CompareFloats: 110ms 125ms -12.2% 110ms 127ms -13.2%
CompareFloatsIntegers: 172ms 143ms +20.7% 173ms 145ms +19.3%
CompareIntegers: 87ms 84ms +4.0% 90ms 85ms +6.0%
CompareInternedStrings: 98ms 121ms -19.1% 99ms 125ms -21.1%
CompareLongs: 112ms 99ms +13.4% 117ms 101ms +15.3%
CompareStrings: 124ms 138ms -10.3% 137ms 146ms -6.2%
CompareUnicode: 125ms 117ms +6.5% 126ms 119ms +6.1%
ComplexPythonFunctionCalls: 268ms 175ms +53.3% 271ms 177ms +52.9%
ConcatStrings: 370ms 325ms +13.8% 374ms 370ms +0.9%
ConcatUnicode: 438ms 331ms +32.2% 460ms 379ms +21.4%
CreateInstances: 197ms 176ms +11.8% 199ms 179ms +11.0%
CreateNewInstances: 163ms 135ms +21.0% 169ms 137ms +23.1%
CreateStringsWithConcat: 135ms 122ms +11.0% 137ms 124ms +10.9%
CreateUnicodeWithConcat: 213ms 134ms +58.9% 216ms 137ms +58.1%
DictCreation: 124ms 106ms +17.2% 129ms 108ms +18.7%
DictWithFloatKeys: 321ms 306ms +4.9% 323ms 312ms +3.6%
DictWithIntegerKeys: 97ms 100ms -2.6% 99ms 102ms -3.3%
DictWithStringKeys: 108ms 107ms +0.5% 109ms 109ms -0.5%
ForLoops: 75ms 68ms +9.4% 75ms 70ms +7.1%
IfThenElse: 94ms 94ms -0.2% 100ms 96ms +4.4%
ListSlicing: 185ms 175ms +5.9% 191ms 178ms +7.2%
NestedForLoops: 128ms 100ms +27.9% 131ms 103ms +26.8%
NestedListComprehensions: 175ms 173ms +1.4% 184ms 181ms +2.0%
NormalClassAttribute: 130ms 119ms +9.9% 133ms 120ms +10.8%
NormalInstanceAttribute: 122ms 106ms +15.5% 127ms 108ms +17.3%
PythonFunctionCalls: 153ms 167ms -8.5% 154ms 170ms -9.1%
PythonMethodCalls: 194ms 188ms +3.0% 205ms 192ms +6.8%
Recursion: 205ms 228ms -10.1% 208ms 231ms -9.8%
SecondImport: 133ms 124ms +7.8% 137ms 126ms +9.4%
SecondPackageImport: 139ms 136ms +2.4% 142ms 138ms +3.0%
SecondSubmoduleImport: 187ms 183ms +2.5% 190ms 186ms +1.9%
SimpleComplexArithmetic: 171ms 133ms +28.7% 173ms 134ms +29.0%
SimpleDictManipulation: 114ms 123ms -7.7% 118ms 125ms -6.1%
SimpleFloatArithmetic: 165ms 109ms +51.5% 170ms 127ms +33.5%
SimpleIntFloatArithmetic: 85ms 84ms +1.7% 85ms 85ms +0.3%
SimpleIntegerArithmetic: 85ms 83ms +1.8% 85ms 84ms +1.5%
SimpleListComprehensions: 144ms 140ms +3.0% 151ms 146ms +3.9%
SimpleListManipulation: 83ms 94ms -11.9% 85ms 97ms -12.5%
SimpleLongArithmetic: 137ms 121ms +12.5% 138ms 123ms +12.2%
SmallLists: 183ms 173ms +5.9% 189ms 177ms +7.0%
SmallTuples: 169ms 145ms +16.5% 173ms 147ms +17.5%
SpecialClassAttribute: 128ms 117ms +9.0% 133ms 119ms +11.3%
SpecialInstanceAttribute: 213ms 122ms +75.0% 216ms 127ms +69.8%
StringMappings: 806ms 236ms +242.2% 840ms 240ms +250.1%
StringPredicates: 278ms 182ms +52.6% 284ms 185ms +53.1%
StringSlicing: 179ms 157ms +14.0% 182ms 160ms +13.7%
TryExcept: 82ms 60ms +37.0% 83ms 61ms +36.1%
TryRaiseExcept: 212ms 117ms +81.8% 218ms 120ms +82.5%
TupleSlicing: 167ms 153ms +9.1% 173ms 155ms +11.4%
UnicodeMappings: 135ms 100ms +35.6% 136ms 102ms +33.9%
UnicodePredicates: 164ms 130ms +26.3% 165ms 132ms +25.5%
UnicodeProperties: 165ms 133ms +24.6% 167ms 138ms +21.2%
UnicodeSlicing: 245ms 174ms +40.7% 248ms 177ms +39.9%
-------------------------------------------------------------------------------
Totals: 9715ms 7938ms +22.4% 9964ms 8200ms +21.5%
(this=p24.pybench, other=p26.pybench)
首先在google中搜索"python benchmark",找到一篇资料,说是python26>python25>python24,加上psyco大概有十倍的效率提升。(具体link找不到了,汗)
然后自己测试了一下,使用pybench([url]http://svn.python.org/projects/python/trunk/Tools/pybench[/url]),结果如下:
python 2.6 比python2.4 快了大概20%
python 2.5 的执行效率和python2.4基本上差不多 大概1%-2%的提升
具体数据见附件
本来还想测试加上psyco后的效率,暂时还没弄好怎么用,晚点再说
不过可以肯定的一点是,可以放心在项目中用python26了
E:\stduy\vituallife\doc\spring\python\benchmark\pybench\svn.python.org\projects\python\trunk\Tools\pybench>d:\Python26\python.exe pybench.py -s p24.pybench -c p26.pybench
-------------------------------------------------------------------------------
PYBENCH 2.0
-------------------------------------------------------------------------------
* using CPython 2.6.2c1 (r262c1:71369, Apr 7 2009, 18:44:00) [MSC v.1500 32 bit (Intel)]
* disabled garbage collection
* system check interval set to maximum: 2147483647
* using timer: time.clock
-------------------------------------------------------------------------------
Benchmark: p24.pybench
-------------------------------------------------------------------------------
Rounds: 10
Warp: 10
Timer: time.clock
Machine Details:
Platform ID: Windows-32bit
Processor:
Python:
Implementation: n/a
Executable: d:\Python24\python.exe
Version: 2.4.4
Compiler: MSC v.1310 32 bit (Intel)
Bits: 32bit
Build: Oct 18 2006 08:34:43 (#71)
Unicode: UCS2
-------------------------------------------------------------------------------
Comparing with: p26.pybench
-------------------------------------------------------------------------------
Rounds: 10
Warp: 10
Timer: time.clock
Machine Details:
Platform ID: Windows-XP-5.1.2600-SP2
Processor: x86 Family 15 Model 4 Stepping 1, GenuineIntel
Python:
Implementation: CPython
Executable: d:\Python26\python.exe
Version: 2.6.2c1
Compiler: MSC v.1500 32 bit (Intel)
Bits: 32bit
Build: Apr 7 2009 18:44:00 (#r262c1:71369)
Unicode: UCS2
Test minimum run-time average run-time
this other diff this other diff
-------------------------------------------------------------------------------
BuiltinFunctionCalls: 212ms 170ms +24.8% 219ms 175ms +25.1%
BuiltinMethodLookup: 210ms 179ms +17.6% 219ms 183ms +19.4%
CompareFloats: 110ms 125ms -12.2% 110ms 127ms -13.2%
CompareFloatsIntegers: 172ms 143ms +20.7% 173ms 145ms +19.3%
CompareIntegers: 87ms 84ms +4.0% 90ms 85ms +6.0%
CompareInternedStrings: 98ms 121ms -19.1% 99ms 125ms -21.1%
CompareLongs: 112ms 99ms +13.4% 117ms 101ms +15.3%
CompareStrings: 124ms 138ms -10.3% 137ms 146ms -6.2%
CompareUnicode: 125ms 117ms +6.5% 126ms 119ms +6.1%
ComplexPythonFunctionCalls: 268ms 175ms +53.3% 271ms 177ms +52.9%
ConcatStrings: 370ms 325ms +13.8% 374ms 370ms +0.9%
ConcatUnicode: 438ms 331ms +32.2% 460ms 379ms +21.4%
CreateInstances: 197ms 176ms +11.8% 199ms 179ms +11.0%
CreateNewInstances: 163ms 135ms +21.0% 169ms 137ms +23.1%
CreateStringsWithConcat: 135ms 122ms +11.0% 137ms 124ms +10.9%
CreateUnicodeWithConcat: 213ms 134ms +58.9% 216ms 137ms +58.1%
DictCreation: 124ms 106ms +17.2% 129ms 108ms +18.7%
DictWithFloatKeys: 321ms 306ms +4.9% 323ms 312ms +3.6%
DictWithIntegerKeys: 97ms 100ms -2.6% 99ms 102ms -3.3%
DictWithStringKeys: 108ms 107ms +0.5% 109ms 109ms -0.5%
ForLoops: 75ms 68ms +9.4% 75ms 70ms +7.1%
IfThenElse: 94ms 94ms -0.2% 100ms 96ms +4.4%
ListSlicing: 185ms 175ms +5.9% 191ms 178ms +7.2%
NestedForLoops: 128ms 100ms +27.9% 131ms 103ms +26.8%
NestedListComprehensions: 175ms 173ms +1.4% 184ms 181ms +2.0%
NormalClassAttribute: 130ms 119ms +9.9% 133ms 120ms +10.8%
NormalInstanceAttribute: 122ms 106ms +15.5% 127ms 108ms +17.3%
PythonFunctionCalls: 153ms 167ms -8.5% 154ms 170ms -9.1%
PythonMethodCalls: 194ms 188ms +3.0% 205ms 192ms +6.8%
Recursion: 205ms 228ms -10.1% 208ms 231ms -9.8%
SecondImport: 133ms 124ms +7.8% 137ms 126ms +9.4%
SecondPackageImport: 139ms 136ms +2.4% 142ms 138ms +3.0%
SecondSubmoduleImport: 187ms 183ms +2.5% 190ms 186ms +1.9%
SimpleComplexArithmetic: 171ms 133ms +28.7% 173ms 134ms +29.0%
SimpleDictManipulation: 114ms 123ms -7.7% 118ms 125ms -6.1%
SimpleFloatArithmetic: 165ms 109ms +51.5% 170ms 127ms +33.5%
SimpleIntFloatArithmetic: 85ms 84ms +1.7% 85ms 85ms +0.3%
SimpleIntegerArithmetic: 85ms 83ms +1.8% 85ms 84ms +1.5%
SimpleListComprehensions: 144ms 140ms +3.0% 151ms 146ms +3.9%
SimpleListManipulation: 83ms 94ms -11.9% 85ms 97ms -12.5%
SimpleLongArithmetic: 137ms 121ms +12.5% 138ms 123ms +12.2%
SmallLists: 183ms 173ms +5.9% 189ms 177ms +7.0%
SmallTuples: 169ms 145ms +16.5% 173ms 147ms +17.5%
SpecialClassAttribute: 128ms 117ms +9.0% 133ms 119ms +11.3%
SpecialInstanceAttribute: 213ms 122ms +75.0% 216ms 127ms +69.8%
StringMappings: 806ms 236ms +242.2% 840ms 240ms +250.1%
StringPredicates: 278ms 182ms +52.6% 284ms 185ms +53.1%
StringSlicing: 179ms 157ms +14.0% 182ms 160ms +13.7%
TryExcept: 82ms 60ms +37.0% 83ms 61ms +36.1%
TryRaiseExcept: 212ms 117ms +81.8% 218ms 120ms +82.5%
TupleSlicing: 167ms 153ms +9.1% 173ms 155ms +11.4%
UnicodeMappings: 135ms 100ms +35.6% 136ms 102ms +33.9%
UnicodePredicates: 164ms 130ms +26.3% 165ms 132ms +25.5%
UnicodeProperties: 165ms 133ms +24.6% 167ms 138ms +21.2%
UnicodeSlicing: 245ms 174ms +40.7% 248ms 177ms +39.9%
-------------------------------------------------------------------------------
Totals: 9715ms 7938ms +22.4% 9964ms 8200ms +21.5%
(this=p24.pybench, other=p26.pybench)