Commit a50e6233 authored by Marc-André Lemburg's avatar Marc-André Lemburg

Add Python implementation to the machine details.

Pretty-print the Python version used for running PyBench.

Let the user know when calibration has finished.

[ 1563844 ] pybench support for IronPython:

Simplify Unicode version detection.

Make garbage collection and check interval settings optional if
the Python implementation doesn't support thess (e.g. IronPython).
parent 10514a70
...@@ -34,7 +34,7 @@ NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION ...@@ -34,7 +34,7 @@ NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! WITH THE USE OR PERFORMANCE OF THIS SOFTWARE !
""" """
import sys, time, operator, string import sys, time, operator, string, platform
from CommandLine import * from CommandLine import *
try: try:
...@@ -102,27 +102,26 @@ def get_timer(timertype): ...@@ -102,27 +102,26 @@ def get_timer(timertype):
def get_machine_details(): def get_machine_details():
import platform
if _debug: if _debug:
print 'Getting machine details...' print 'Getting machine details...'
buildno, builddate = platform.python_build() buildno, builddate = platform.python_build()
python = platform.python_version() python = platform.python_version()
if python > '2.0': try:
try: unichr(100000)
unichr(100000) except ValueError:
except ValueError: # UCS2 build (standard)
# UCS2 build (standard) unicode = 'UCS2'
unicode = 'UCS2' except NameError:
else:
# UCS4 build (most recent Linux distros)
unicode = 'UCS4'
else:
unicode = None unicode = None
else:
# UCS4 build (most recent Linux distros)
unicode = 'UCS4'
bits, linkage = platform.architecture() bits, linkage = platform.architecture()
return { return {
'platform': platform.platform(), 'platform': platform.platform(),
'processor': platform.processor(), 'processor': platform.processor(),
'executable': sys.executable, 'executable': sys.executable,
'implementation': platform.python_implementation(),
'python': platform.python_version(), 'python': platform.python_version(),
'compiler': platform.python_compiler(), 'compiler': platform.python_compiler(),
'buildno': buildno, 'buildno': buildno,
...@@ -134,17 +133,18 @@ def get_machine_details(): ...@@ -134,17 +133,18 @@ def get_machine_details():
def print_machine_details(d, indent=''): def print_machine_details(d, indent=''):
l = ['Machine Details:', l = ['Machine Details:',
' Platform ID: %s' % d.get('platform', 'n/a'), ' Platform ID: %s' % d.get('platform', 'n/a'),
' Processor: %s' % d.get('processor', 'n/a'), ' Processor: %s' % d.get('processor', 'n/a'),
'', '',
'Python:', 'Python:',
' Executable: %s' % d.get('executable', 'n/a'), ' Implementation: %s' % d.get('implementation', 'n/a'),
' Version: %s' % d.get('python', 'n/a'), ' Executable: %s' % d.get('executable', 'n/a'),
' Compiler: %s' % d.get('compiler', 'n/a'), ' Version: %s' % d.get('python', 'n/a'),
' Bits: %s' % d.get('bits', 'n/a'), ' Compiler: %s' % d.get('compiler', 'n/a'),
' Build: %s (#%s)' % (d.get('builddate', 'n/a'), ' Bits: %s' % d.get('bits', 'n/a'),
d.get('buildno', 'n/a')), ' Build: %s (#%s)' % (d.get('builddate', 'n/a'),
' Unicode: %s' % d.get('unicode', 'n/a'), d.get('buildno', 'n/a')),
' Unicode: %s' % d.get('unicode', 'n/a'),
] ]
print indent + string.join(l, '\n' + indent) + '\n' print indent + string.join(l, '\n' + indent) + '\n'
...@@ -499,8 +499,9 @@ class Benchmark: ...@@ -499,8 +499,9 @@ class Benchmark:
def calibrate(self): def calibrate(self):
print 'Calibrating tests. Please wait...' print 'Calibrating tests. Please wait...',
if self.verbose: if self.verbose:
print
print print
print 'Test min max' print 'Test min max'
print '-' * LINE print '-' * LINE
...@@ -514,6 +515,11 @@ class Benchmark: ...@@ -514,6 +515,11 @@ class Benchmark:
(name, (name,
min(test.overhead_times) * MILLI_SECONDS, min(test.overhead_times) * MILLI_SECONDS,
max(test.overhead_times) * MILLI_SECONDS) max(test.overhead_times) * MILLI_SECONDS)
if self.verbose:
print
print 'Done with the calibration.'
else:
print 'done.'
print print
def run(self): def run(self):
...@@ -830,7 +836,9 @@ python pybench.py -s p25.pybench -c p21.pybench ...@@ -830,7 +836,9 @@ python pybench.py -s p25.pybench -c p21.pybench
print '-' * LINE print '-' * LINE
print 'PYBENCH %s' % __version__ print 'PYBENCH %s' % __version__
print '-' * LINE print '-' * LINE
print '* using Python %s' % (string.split(sys.version)[0]) print '* using %s %s' % (
platform.python_implementation(),
string.join(string.split(sys.version), ' '))
# Switch off garbage collection # Switch off garbage collection
if not withgc: if not withgc:
...@@ -839,15 +847,23 @@ python pybench.py -s p25.pybench -c p21.pybench ...@@ -839,15 +847,23 @@ python pybench.py -s p25.pybench -c p21.pybench
except ImportError: except ImportError:
print '* Python version doesn\'t support garbage collection' print '* Python version doesn\'t support garbage collection'
else: else:
gc.disable() try:
print '* disabled garbage collection' gc.disable()
except NotImplementedError:
print '* Python version doesn\'t support gc.disable'
else:
print '* disabled garbage collection'
# "Disable" sys check interval # "Disable" sys check interval
if not withsyscheck: if not withsyscheck:
# Too bad the check interval uses an int instead of a long... # Too bad the check interval uses an int instead of a long...
value = 2147483647 value = 2147483647
sys.setcheckinterval(value) try:
print '* system check interval set to maximum: %s' % value sys.setcheckinterval(value)
except NotImplementedError:
print '* Python version doesn\'t support sys.setcheckinterval'
else:
print '* system check interval set to maximum: %s' % value
if timer == TIMER_SYSTIMES_PROCESSTIME: if timer == TIMER_SYSTIMES_PROCESSTIME:
import systimes import systimes
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment