Ported PyBench to Jython, ran a few benchmarks against python
2008-07-02 20:02:45 GMT
Here's a rough patch for PyBench (a python benchmark designed to test various python implementations). It should now run on Jython.
Would be interesting to see a few more user testing and platforms. Mine is Solaris.
Using Jython (svn):
==================
Jython 2.3a0+ (trunk:4838M, Jul 2 2008, 22:18:30)
[Java HotSpot(TM) Server VM (Sun Microsystems Inc.)] on java1.6.0_06
cthulhu% ./pybench.py
-------------------------------------------------------------------------------
PYBENCH 2.0
-------------------------------------------------------------------------------
* Python version doesn't support gc.disable
* Python version doesn't support sys.setcheckinterval
* using timer: time.time
Calibrating tests. Please wait... done.
Running 10 round(s) of the suite at warp factor 10:
* Round 1 done in 15.507 seconds.
* Round 2 done in 13.738 seconds.
* Round 3 done in 9.633 seconds.
* Round 4 done in 8.087 seconds.
* Round 5 done in 7.980 seconds.
* Round 6 done in 7.784 seconds.
* Round 7 done in 7.727 seconds.
* Round 8 done in 7.729 seconds.
* Round 9 done in 7.743 seconds.
* Round 10 done in 7.668 seconds.
-------------------------------------------------------------------------------
Benchmark: 2008-07-02 22:41:31
-------------------------------------------------------------------------------
Rounds: 10
Warp: 10
Timer: time.time
Test minimum average operation overhead
-------------------------------------------------------------------------------
BuiltinFunctionCalls: 36ms 69ms 0.14us 0.500ms
BuiltinMethodLookup: 72ms 124ms 0.12us 0.550ms
CompareFloats: 38ms 74ms 0.06us 0.650ms
CompareFloatsIntegers: 69ms 95ms 0.11us 0.500ms
CompareIntegers: 62ms 96ms 0.05us 0.950ms
CompareInternedStrings: 2.75us 0.300ms
CreateStringsWithConcat: 151ms 176ms 0.18us 0.550ms
CreateUnicodeWithConcat: 69ms 85ms 0.21us 0.200ms
DictCreation: 556ms 607ms 1.52us 0.200ms
DictWithFloatKeys: 97ms 132ms 0.15us 0.400ms
DictWithIntegerKeys: 81ms 101ms 0.08us 0.550ms
DictWithStringKeys: 88ms 110ms 0.09us 0.550ms
ForLoops: 88ms 137ms 5.50us 0.000ms
IfThenElse: 350ms 353ms 0.26us 0.400ms
ListSlicing: 46ms 56ms 4.02us 0.050ms
NestedForLoops: 87ms 93ms 0.06us 0.000ms
NormalClassAttribute: 99ms 140ms 0.12us 0.250ms
NormalInstanceAttribute: 92ms 135ms 0.11us 0.250ms
PythonFunctionCalls: 88ms 132ms 0.40us 0.150ms
PythonMethodCalls: 109ms 149ms 0.66us 0.100ms
Recursion: 125ms 131ms 2.61us 0.250ms
SecondImport: 125ms 145ms 1.45us 0.100ms
SecondPackageImport: 133ms 141ms 1.41us 0.100ms
SecondSubmoduleImport: 210ms 218ms 2.18us 0.100ms
SimpleComplexArithmetic: 52ms 99ms 0.11us 0.200ms
SimpleDictManipulation: 87ms 148ms 0.12us 0.250ms
SimpleFloatArithmetic: 56ms 137ms 0.10us 0.300ms
SimpleIntFloatArith 130ms 0.11us 0.250ms
StringMappings: 213ms 228ms 0.90us 0.250ms
StringPredicates: 82ms 110ms 0.16us 0.700ms
StringSlicing: 51ms 77ms 0.14us 0.450ms
TryExcept: 3ms 14ms 0.01us 0.400ms
TryRaiseExcept: 651ms 691ms 10.79us 0.200ms
TupleSlicing: 78ms 126ms 0.48us 0.050ms
UnicodeMappings: 163ms 181ms 5.02us 0.400ms
UnicodePredicates: 66ms 107ms 0.20us 0.950ms
UnicodeSlicing: 1355ms 1387ms 2.83us 0.400ms
-------------------------------------------------------------------------------
Totals: 7600ms 9359ms
Using Python:
=============
Python 2.4.4 (#1, May 19 2008, 02:13:30) [C] on sunos5
cthulhu% ./pybench.py
-------------------------------------------------------------------------------
PYBENCH 2.0
-------------------------------------------------------------------------------
* disabled garbage collection
* system check interval set to maximum: 2147483647
* using timer: time.time
Calibrating tests. Please wait... done.
Running 10 round(s) of the suite at warp factor 10:
* Round 1 done in 6.896 seconds.
* Round 2 done in 6.803 seconds.
* Round 3 done in 6.814 seconds.
* Round 4 done in 6.774 seconds.
* Round 5 done in 6.797 seconds.
* Round 6 done in 6.801 seconds.
* Round 7 done in 6.776 seconds.
* Round 8 done in 6.761 seconds.
* Round 9 done in 6.766 seconds.
* Round 10 done in 6.833 seconds.
--------0.11us 0.217ms
CompareFloats: 87ms 87ms 0.07us 0.249ms
CompareFloatsIntegers: 101ms 102ms 0.11us 0.186ms
CompareIntegers: 78ms 78ms 0.04us 0.373ms
CompareInternedStrings: 128ms 130ms 0.09us 0.940ms
CompareLongs: 90ms 91ms 0.09us 0.215ms
CompareStrings: 97ms 98ms 0.10us 0.627ms
CompareUnicode: 102ms 103ms 0.14us 0.477ms
ConcatStrings: 166ms 177ms 0.35us 0.415ms
ConcatUnicode: 124ms 139ms 0.46us 0.296ms
CreateInstances: 169ms 170ms 1.52us 0.252ms
CreateNewInstances: 148ms 149ms 1.77us 0.251ms
CreateStringsWithConcat: 124ms 124ms 0.12us 0.616ms
CreateUnicodeWithConcat: 172ms 175ms 0.44us 0.246ms
DictCreation: 96ms 98ms 0.25us 0.246ms
DictWithFloatKeys: 163ms 164ms 0.18us 0.459ms
DictWithIntegerKeys: 103ms 104ms 0.09us 0.616ms
DictWithStringKeys: 88ms 90ms 0.08us 0.616ms
ForLoops: 66ms 66ms 2.66us 0.058ms
IfThenElse: 69ms 69ms 0.05us 0.466ms
ListSlicing: 68ms 69ms 4.90us 0.067ms
NestedForLoops: 95ms 96ms 0.06us 0.020ms
NormalClassAttrib 128ms 1.28us 0.123ms
SimpleComplexArithmetic: 153ms 154ms 0.18us 0.248ms
SimpleDictManipulation: 150ms 153ms 0.13us 0.311ms
SimpleFloatArithmetic: 107ms 108ms 0.08us 0.369ms
SimpleIntFloatArithmetic: 83ms 83ms 0.06us 0.371ms
SimpleIntegerArithmetic: 82ms 83ms 0.06us 0.372ms
SimpleListManipulation: 139ms 139ms 0.12us 0.403ms
SimpleLongArithmetic: 133ms 134ms 0.20us 0.214ms
SmallLists: 169ms 170ms 0.25us 0.247ms
SmallTuples: 142ms 143ms 0.26us 0.277ms
SpecialClassAttribute: 112ms 113ms 0.09us 0.311ms
SpecialInstanceAttribute: 181ms 183ms 0.15us 0.310ms
StringMappings: 134ms 134ms 0.53us 0.347ms
StringPredicates: 206ms 206ms 0.29us 1.659ms
StringSlicing: 167ms 168ms 0.30us 0.546ms
---------------------------------------------------------------
Totals: 6691ms 6802ms
PyBench is Revision 64668: /python/trunk/Tools/pybench
http://svn.python.org/projects/python/trunk/Tools/pybench/
svn patch for PyBench (port to Jython):
Index: pybench.py
===================================================================
--- pybench.py (revision 64668)
+++ pybench.py (working copy)
<at> <at> -1,4 +1,4 <at> <at>
-#!/usr/local/bin/python -O
+#!/usr/local/bin/python
""" A Python Benchmark Suite
<at> <at> -34,7 +34,7 <at> <at>
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE !
"""
-import sys, time, operator, string, platform
+import sys, time, operator, string
from CommandLine import *
try:
<at> <at> -100,55 +100,7 <at> <at>
else:
raise TypeError('unknown timer type: %s' % timertype)
-def get_machine_details():
- if _debug:
- print 'Getting machine details...'
- buildno, builddate = platform.python_build()
- python = platform.python_version()
- try:
- unichr(100000)
- except ValueError:
- # UCS2 build (standard)
- unicode = 'UCS2'
- except NameError:
- unicode = None
- else:
- # UCS4 build (most recent Linux distros)
- unicode = 'UCS4'
- bits, linkage = platform.architecture()
- return {
- 'platform': platform.platform(),
- 'processor': platform.processor(),
- 'executable': sys.executable,
- 'implementation': getattr(platform, 'python_implementation',
- lambda:'n/a')(),
- 'python': platform.python_version(),
- 'compiler': platform.python_compiler(),
- 'buildno': buildno,
- 'builddate': builddate,
- 'unicode': unicode,
- 'bits': bits,
- }
-
-def print_machine_details(d, indent=''):
-
- l = ['Machine Details:',
- ' Platform ID: %s' % d.get('platform', 'n/a'),
- ' Processor: %s' % d.get('processor', 'n/a'),
- '',
- 'Python:',
- ' Implementation: %s' % d.get('implementation', 'n/a'),
- ' Executable: %s' % d.get('executable', 'n/a'),
- ' Version: %s' % d.get('python', 'n/a'),
- ' Compiler: %s' % d.get('compiler', 'n/a'),
- ' Bits: %s' % d.get('bits', 'n/a'),
- ' Build: %s (#%s)' % (d.get('builddate', 'n/a'),
- d.get('buildno', 'n/a')),
- ' Unicode: %s' % d.get('unicode', 'n/a'),
- ]
- print indent + string.join(l, '\n' + indent) + '\n'
-
### Test baseclass
class Test:
<at> <at> -438,7 +390,6 <at> <at>
self.tests = {}
if _debug:
print 'Getting machine details...'
- self.machine_details = get_machine_details()
# Make .version an instance attribute to have it saved in the
# Benchmark pickle
<at> <at> -457,17 +408,6 <at> <at>
compatible with the other Benchmark instance or not.
"""
- if self.version != other.version:
- return 0
- if (self.machine_details == other.machine_details and
- self.timer != other.timer):
- return 0
- if (self.calibration_runs == 0 and
- other.calibration_runs != 0):
- return 0
- if (self.calibration_runs != 0 and
- other.calibration_runs == 0):
- return 0
return 1
def load_tests(self, setupmod, limitnames=None):
<at> <at> -593,9 +533,6 <at> <at>
print ' Warp: %s' % self.warp
print ' Timer: %s' % self.timer
print
- if self.machine_details:
- print_machine_details(self.machine_details, indent=' ')
- print
def print_benchmark(self, hidenoise=0, limitnames=None):
<at> <at> -838,9 +775,6 <at> <at>
print '-' * LINE
print 'PYBENCH %s' % __version__
print '-' * LINE
- print '* using %s %s' % (
- getattr(platform, 'python_implementation', lambda:'Python')(),
- string.join(string.split(sys.version), ' '))
# Switch off garbage collection
if not withgc:
Platform information:
--------------------
cthulhu% prtdiag
System Configuration: Acer, inc. Aspire 5920G
BIOS Configuration: Acer v0.3508 05/22/2007
Core 2 Duo T7300 <at> 2Ghz, 4MB Cache
2GB DDR 667
cthulhu% uname -a
SunOS cthulhu 5.11 snv_91 i86pc i386 i86pc
cthulhu% cat /etc/release
Solaris Express Community Edition snv_91 X86
Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
Use is subject to license terms.
Assembled 03 June 2008
--
Criveti Mihai
http://unixsadm.blogspot.com
------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________ Jython-users mailing list Jython-users <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jython-users
RSS Feed