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:
unicode = None
else: else:
# UCS4 build (most recent Linux distros) # UCS4 build (most recent Linux distros)
unicode = 'UCS4' unicode = 'UCS4'
else:
unicode = None
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,
...@@ -138,6 +137,7 @@ def print_machine_details(d, indent=''): ...@@ -138,6 +137,7 @@ def print_machine_details(d, indent=''):
' Processor: %s' % d.get('processor', 'n/a'), ' Processor: %s' % d.get('processor', 'n/a'),
'', '',
'Python:', 'Python:',
' Implementation: %s' % d.get('implementation', 'n/a'),
' Executable: %s' % d.get('executable', 'n/a'), ' Executable: %s' % d.get('executable', 'n/a'),
' Version: %s' % d.get('python', 'n/a'), ' Version: %s' % d.get('python', 'n/a'),
' Compiler: %s' % d.get('compiler', 'n/a'), ' Compiler: %s' % d.get('compiler', 'n/a'),
...@@ -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,14 +847,22 @@ python pybench.py -s p25.pybench -c p21.pybench ...@@ -839,14 +847,22 @@ 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:
try:
gc.disable() gc.disable()
except NotImplementedError:
print '* Python version doesn\'t support gc.disable'
else:
print '* disabled garbage collection' 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
try:
sys.setcheckinterval(value) sys.setcheckinterval(value)
except NotImplementedError:
print '* Python version doesn\'t support sys.setcheckinterval'
else:
print '* system check interval set to maximum: %s' % value print '* system check interval set to maximum: %s' % value
if timer == TIMER_SYSTIMES_PROCESSTIME: if timer == TIMER_SYSTIMES_PROCESSTIME:
......
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