diff options
author | Guido van Rossum <guido@python.org> | 2007-06-30 05:01:58 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-06-30 05:01:58 (GMT) |
commit | 486364b821ad25bc33e7247539d2c48a9e3b7051 (patch) | |
tree | 72b5efdf5cb3947fe5ead2849075dfdf7de28a7d /Tools | |
parent | 8ddff70822d4d6d739a659138801e690a78939d7 (diff) | |
download | cpython-486364b821ad25bc33e7247539d2c48a9e3b7051.zip cpython-486364b821ad25bc33e7247539d2c48a9e3b7051.tar.gz cpython-486364b821ad25bc33e7247539d2c48a9e3b7051.tar.bz2 |
Merged revisions 56020-56124 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r56037 | georg.brandl | 2007-06-19 05:33:20 -0700 (Tue, 19 Jun 2007) | 2 lines
Patch #1739659: don't slice dict.keys() in pydoc.
................
r56060 | martin.v.loewis | 2007-06-21 13:00:02 -0700 (Thu, 21 Jun 2007) | 2 lines
Regenerate to add True, False, None.
................
r56069 | neal.norwitz | 2007-06-21 22:31:56 -0700 (Thu, 21 Jun 2007) | 1 line
Get the doctest working again after adding None, True, and False as kewyords.
................
r56070 | neal.norwitz | 2007-06-21 23:25:33 -0700 (Thu, 21 Jun 2007) | 1 line
Add space to error message.
................
r56071 | neal.norwitz | 2007-06-21 23:40:04 -0700 (Thu, 21 Jun 2007) | 6 lines
Get pybench working, primarily
* Use print function
* Stop using string module
* Use sorted instead of assuming dict methods return lists
* Convert range result to a list
................
r56089 | collin.winter | 2007-06-26 10:31:48 -0700 (Tue, 26 Jun 2007) | 1 line
Fix AttributeError in distutils/dir_util.py.
................
r56124 | guido.van.rossum | 2007-06-29 18:04:31 -0700 (Fri, 29 Jun 2007) | 30 lines
Merged revisions 56014-56123 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r56019 | lars.gustaebel | 2007-06-18 04:42:11 -0700 (Mon, 18 Jun 2007) | 2 lines
Added exclude keyword argument to the TarFile.add() method.
........
r56023 | lars.gustaebel | 2007-06-18 13:05:55 -0700 (Mon, 18 Jun 2007) | 3 lines
Added missing \versionchanged tag for the new exclude
parameter.
........
r56038 | georg.brandl | 2007-06-19 05:36:00 -0700 (Tue, 19 Jun 2007) | 2 lines
Bug #1737864: allow empty message in logging format routines.
........
r56040 | georg.brandl | 2007-06-19 05:38:20 -0700 (Tue, 19 Jun 2007) | 2 lines
Bug #1739115: make shutil.rmtree docs clear wrt. file deletion.
........
r56084 | georg.brandl | 2007-06-25 08:21:23 -0700 (Mon, 25 Jun 2007) | 2 lines
Bug #1742901: document None behavior of shlex.split.
........
r56091 | georg.brandl | 2007-06-27 07:09:56 -0700 (Wed, 27 Jun 2007) | 2 lines
Fix a variable name in winreg docs.
........
................
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/pybench/CommandLine.py | 104 | ||||
-rw-r--r-- | Tools/pybench/Lists.py | 4 | ||||
-rw-r--r-- | Tools/pybench/Strings.py | 41 | ||||
-rw-r--r-- | Tools/pybench/Unicode.py | 37 | ||||
-rw-r--r-- | Tools/pybench/clockres.py | 8 | ||||
-rwxr-xr-x | Tools/pybench/pybench.py | 230 | ||||
-rw-r--r-- | Tools/pybench/systimes.py | 24 |
7 files changed, 223 insertions, 225 deletions
diff --git a/Tools/pybench/CommandLine.py b/Tools/pybench/CommandLine.py index 1cdcfc1..d0142f8 100644 --- a/Tools/pybench/CommandLine.py +++ b/Tools/pybench/CommandLine.py @@ -20,7 +20,7 @@ or contact the author. All Rights Reserved. __version__ = '1.2' -import sys, getopt, string, glob, os, re, exceptions, traceback +import sys, getopt, glob, os, re, traceback ### Helpers @@ -44,7 +44,7 @@ def _getopt_flags(options): l.append(o.name+'=') else: l.append(o.name) - return string.join(s,''),l + return ''.join(s), l def invisible_input(prompt='>>> '): @@ -102,7 +102,7 @@ _integerRangeRE = re.compile('\s*(-?\d+)\s*-\s*(-?\d+)\s*$') def srange(s, - split=string.split,integer=_integerRE, + integer=_integerRE, integerRange=_integerRangeRE): """ Converts a textual representation of integer numbers and ranges @@ -116,7 +116,7 @@ def srange(s, """ l = [] append = l.append - for entry in split(s,','): + for entry in s.split(','): m = integer.match(entry) if m: append(int(m.groups()[0])) @@ -293,7 +293,7 @@ class Application: verbose = 0 # Internal errors to catch - InternalError = exceptions.Exception + InternalError = BaseException # Instance variables: values = None # Dictionary of passed options (or default values) @@ -353,20 +353,20 @@ class Application: pass except KeyboardInterrupt: - print - print '* User Break' - print + print() + print('* User Break') + print() rc = 1 except self.InternalError: - print - print '* Internal Error (use --debug to display the traceback)' + print() + print('* Internal Error (use --debug to display the traceback)') if self.debug: - print + print() traceback.print_exc(20, sys.stdout) elif self.verbose: - print ' %s: %s' % sys.exc_info()[:2] - print + print(' %s: %s' % sys.exc_info()[:2]) + print() rc = 1 raise SystemExit(rc) @@ -449,13 +449,13 @@ class Application: # Try to convert value to integer try: - value = string.atoi(value) + value = int(value) except ValueError: pass # Find handler and call it (or count the number of option # instances on the command line) - handlername = 'handle' + string.replace(optionname, '-', '_') + handlername = 'handle' + optionname.replace('-', '_') try: handler = getattr(self, handlername) except AttributeError: @@ -494,54 +494,55 @@ class Application: self.print_header() if self.synopsis: - print 'Synopsis:' + print('Synopsis:') # To remain backward compatible: try: synopsis = self.synopsis % self.name except (NameError, KeyError, TypeError): synopsis = self.synopsis % self.__dict__ - print ' ' + synopsis - print + print(' ' + synopsis) + print() self.print_options() if self.version: - print 'Version:' - print ' %s' % self.version - print + print('Version:') + print(' %s' % self.version) + print() if self.about: - print string.strip(self.about % self.__dict__) - print + about = self.about % self.__dict__ + print(about.strip()) + print() if note: - print '-'*72 - print 'Note:',note - print + print('-'*72) + print('Note:',note) + print() def notice(self,note): - print '-'*72 - print 'Note:',note - print '-'*72 - print + print('-'*72) + print('Note:',note) + print('-'*72) + print() def print_header(self): - print '-'*72 - print self.header % self.__dict__ - print '-'*72 - print + print('-'*72) + print(self.header % self.__dict__) + print('-'*72) + print() def print_options(self): options = self.options - print 'Options and default settings:' + print('Options and default settings:') if not options: - print ' None' + print(' None') return long = filter(lambda x: x.prefix == '--', options) short = filter(lambda x: x.prefix == '-', options) items = short + long for o in options: - print ' ',o - print + print(' ',o) + print() # # Example handlers: @@ -579,26 +580,29 @@ class Application: self.debug = 1 # We don't want to catch internal errors: - self.InternalError = None + class NoErrorToCatch(Exception): pass + self.InternalError = NoErrorToCatch def handle__copyright(self,arg): self.print_header() - print string.strip(self.copyright % self.__dict__) - print + copyright = self.copyright % self.__dict__ + print(copyright.strip()) + print() return 0 def handle__examples(self,arg): self.print_header() if self.examples: - print 'Examples:' - print - print string.strip(self.examples % self.__dict__) - print + print('Examples:') + print() + examples = self.examples % self.__dict__ + print(examples.strip()) + print() else: - print 'No examples available.' - print + print('No examples available.') + print() return 0 def main(self): @@ -624,13 +628,13 @@ def _test(): options = [Option('-v','verbose')] def handle_v(self,arg): - print 'VERBOSE, Yeah !' + print('VERBOSE, Yeah !') cmd = MyApplication() if not cmd.values['-h']: cmd.help() - print 'files:',cmd.files - print 'Bye...' + print('files:',cmd.files) + print('Bye...') if __name__ == '__main__': _test() diff --git a/Tools/pybench/Lists.py b/Tools/pybench/Lists.py index aedd352..9aeb408 100644 --- a/Tools/pybench/Lists.py +++ b/Tools/pybench/Lists.py @@ -138,8 +138,8 @@ class ListSlicing(Test): def test(self): - n = range(100) - r = range(25) + n = list(range(100)) + r = list(range(25)) for i in range(self.rounds): diff --git a/Tools/pybench/Strings.py b/Tools/pybench/Strings.py index 2668d6b..25e2ad5 100644 --- a/Tools/pybench/Strings.py +++ b/Tools/pybench/Strings.py @@ -1,5 +1,4 @@ from pybench import Test -from string import join import sys class ConcatStrings(Test): @@ -11,8 +10,8 @@ class ConcatStrings(Test): def test(self): # Make sure the strings are *not* interned - s = join(map(str,range(100))) - t = join(map(str,range(1,101))) + s = ''.join(map(str,range(100))) + t = ''.join(map(str,range(1,101))) for i in range(self.rounds): t + s @@ -77,8 +76,8 @@ class ConcatStrings(Test): def calibrate(self): - s = join(map(str,range(100))) - t = join(map(str,range(1,101))) + s = ''.join(map(str,range(100))) + t = ''.join(map(str,range(1,101))) for i in range(self.rounds): pass @@ -93,8 +92,8 @@ class CompareStrings(Test): def test(self): # Make sure the strings are *not* interned - s = join(map(str,range(10))) - t = join(map(str,range(10))) + "abc" + s = ''.join(map(str,range(10))) + t = ''.join(map(str,range(10))) + "abc" for i in range(self.rounds): t < s @@ -159,8 +158,8 @@ class CompareStrings(Test): def calibrate(self): - s = join(map(str,range(10))) - t = join(map(str,range(10))) + "abc" + s = ''.join(map(str,range(10))) + t = ''.join(map(str,range(10))) + "abc" for i in range(self.rounds): pass @@ -175,7 +174,7 @@ class CompareInternedStrings(Test): def test(self): # Make sure the strings *are* interned - s = sys.intern(join(map(str,range(10)))) + s = sys.intern(''.join(map(str,range(10)))) t = s for i in range(self.rounds): @@ -241,7 +240,7 @@ class CompareInternedStrings(Test): def calibrate(self): - s = sys.intern(join(map(str,range(10)))) + s = sys.intern(''.join(map(str,range(10)))) t = s for i in range(self.rounds): @@ -331,7 +330,7 @@ class StringSlicing(Test): def test(self): - s = join(map(str,range(100))) + s = ''.join(map(str,range(100))) for i in range(self.rounds): @@ -377,7 +376,7 @@ class StringSlicing(Test): def calibrate(self): - s = join(map(str,range(100))) + s = ''.join(map(str,range(100))) for i in range(self.rounds): pass @@ -394,10 +393,10 @@ if hasattr('', 'lower'): def test(self): - s = join(map(chr,range(20)),'') - t = join(map(chr,range(50)),'') - u = join(map(chr,range(100)),'') - v = join(map(chr,range(256)),'') + s = ''.join(map(chr,range(20))) + t = ''.join(map(chr,range(50))) + u = ''.join(map(chr,range(100))) + v = ''.join(map(chr,range(256))) for i in range(self.rounds): @@ -451,10 +450,10 @@ if hasattr('', 'lower'): def calibrate(self): - s = join(map(chr,range(20)),'') - t = join(map(chr,range(50)),'') - u = join(map(chr,range(100)),'') - v = join(map(chr,range(256)),'') + s = ''.join(map(chr,range(20))) + t = ''.join(map(chr,range(50))) + u = ''.join(map(chr,range(100))) + v = ''.join(map(chr,range(256))) for i in range(self.rounds): pass diff --git a/Tools/pybench/Unicode.py b/Tools/pybench/Unicode.py index 21e24c0..b17a7c3 100644 --- a/Tools/pybench/Unicode.py +++ b/Tools/pybench/Unicode.py @@ -4,7 +4,6 @@ except NameError: raise ImportError from pybench import Test -from string import join class ConcatUnicode(Test): @@ -15,8 +14,8 @@ class ConcatUnicode(Test): def test(self): # Make sure the strings are *not* interned - s = unicode(join(map(str,range(100)))) - t = unicode(join(map(str,range(1,101)))) + s = unicode(u''.join(map(str,range(100)))) + t = unicode(u''.join(map(str,range(1,101)))) for i in range(self.rounds): t + s @@ -81,8 +80,8 @@ class ConcatUnicode(Test): def calibrate(self): - s = unicode(join(map(str,range(100)))) - t = unicode(join(map(str,range(1,101)))) + s = unicode(u''.join(map(str,range(100)))) + t = unicode(u''.join(map(str,range(1,101)))) for i in range(self.rounds): pass @@ -97,8 +96,8 @@ class CompareUnicode(Test): def test(self): # Make sure the strings are *not* interned - s = unicode(join(map(str,range(10)))) - t = unicode(join(map(str,range(10))) + "abc") + s = unicode(u''.join(map(str,range(10)))) + t = unicode(u''.join(map(str,range(10))) + "abc") for i in range(self.rounds): t < s @@ -163,8 +162,8 @@ class CompareUnicode(Test): def calibrate(self): - s = unicode(join(map(str,range(10)))) - t = unicode(join(map(str,range(10))) + "abc") + s = unicode(u''.join(map(str,range(10)))) + t = unicode(u''.join(map(str,range(10))) + "abc") for i in range(self.rounds): pass @@ -253,7 +252,7 @@ class UnicodeSlicing(Test): def test(self): - s = unicode(join(map(str,range(100)))) + s = unicode(u''.join(map(str,range(100)))) for i in range(self.rounds): @@ -299,7 +298,7 @@ class UnicodeSlicing(Test): def calibrate(self): - s = unicode(join(map(str,range(100)))) + s = unicode(u''.join(map(str,range(100)))) for i in range(self.rounds): pass @@ -314,10 +313,10 @@ class UnicodeMappings(Test): def test(self): - s = join(map(unichr,range(20)),'') - t = join(map(unichr,range(100)),'') - u = join(map(unichr,range(500)),'') - v = join(map(unichr,range(1000)),'') + s = u''.join(map(unichr,range(20))) + t = u''.join(map(unichr,range(100))) + u = u''.join(map(unichr,range(500))) + v = u''.join(map(unichr,range(1000))) for i in range(self.rounds): @@ -371,10 +370,10 @@ class UnicodeMappings(Test): def calibrate(self): - s = join(map(unichr,range(20)),'') - t = join(map(unichr,range(100)),'') - u = join(map(unichr,range(500)),'') - v = join(map(unichr,range(1000)),'') + s = u''.join(map(unichr,range(20))) + t = u''.join(map(unichr,range(100))) + u = u''.join(map(unichr,range(500))) + v = u''.join(map(unichr,range(1000))) for i in range(self.rounds): pass diff --git a/Tools/pybench/clockres.py b/Tools/pybench/clockres.py index 64095b3..42f5ee7 100644 --- a/Tools/pybench/clockres.py +++ b/Tools/pybench/clockres.py @@ -33,11 +33,11 @@ def clockres(timer): return min_diff if __name__ == '__main__': - print 'Clock resolution of various timer implementations:' - print 'time.clock: %10.3fus' % (clockres(time.clock) * 1e6) - print 'time.time: %10.3fus' % (clockres(time.time) * 1e6) + print('Clock resolution of various timer implementations:') + print('time.clock: %10.3fus' % (clockres(time.clock) * 1e6)) + print('time.time: %10.3fus' % (clockres(time.time) * 1e6)) try: import systimes - print 'systimes.processtime: %10.3fus' % (clockres(systimes.processtime) * 1e6) + print('systimes.processtime: %10.3fus' % (clockres(systimes.processtime) * 1e6)) except ImportError: pass diff --git a/Tools/pybench/pybench.py b/Tools/pybench/pybench.py index 6c9d445..17b4704 100755 --- a/Tools/pybench/pybench.py +++ b/Tools/pybench/pybench.py @@ -34,7 +34,7 @@ NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! """ -import sys, time, operator, string, platform +import sys, time, operator, platform from CommandLine import * try: @@ -103,7 +103,7 @@ def get_timer(timertype): def get_machine_details(): if _debug: - print 'Getting machine details...' + print('Getting machine details...') buildno, builddate = platform.python_build() python = platform.python_version() try: @@ -146,7 +146,8 @@ def print_machine_details(d, indent=''): d.get('buildno', 'n/a')), ' Unicode: %s' % d.get('unicode', 'n/a'), ] - print indent + string.join(l, '\n' + indent) + '\n' + joiner = '\n' + indent + print(indent + joiner.join(l) + '\n') ### Test baseclass @@ -280,9 +281,9 @@ class Test: prep_times.append(t) min_prep_time = min(prep_times) if _debug: - print - print 'Calib. prep time = %.6fms' % ( - min_prep_time * MILLI_SECONDS) + print() + print('Calib. prep time = %.6fms' % ( + min_prep_time * MILLI_SECONDS)) # Time the calibration runs (doing CALIBRATION_LOOPS loops of # .calibrate() method calls each) @@ -298,8 +299,8 @@ class Test: min_overhead = min(self.overhead_times) max_overhead = max(self.overhead_times) if _debug: - print 'Calib. overhead time = %.6fms' % ( - min_overhead * MILLI_SECONDS) + print('Calib. overhead time = %.6fms' % ( + min_overhead * MILLI_SECONDS)) if min_overhead < 0.0: raise ValueError('calibration setup did not work') if max_overhead - min_overhead > 0.1: @@ -436,7 +437,7 @@ class Benchmark: # Init vars self.tests = {} if _debug: - print 'Getting machine details...' + print('Getting machine details...') self.machine_details = get_machine_details() # Make .version an instance attribute to have it saved in the @@ -473,8 +474,8 @@ class Benchmark: # Add tests if self.verbose: - print 'Searching for tests ...' - print '--------------------------------------' + print('Searching for tests ...') + print('--------------------------------------') for testclass in setupmod.__dict__.values(): if not hasattr(testclass, 'is_a_test'): continue @@ -488,77 +489,74 @@ class Benchmark: warp=self.warp, calibration_runs=self.calibration_runs, timer=self.timer) - l = self.tests.keys() - l.sort() + l = sorted(self.tests) if self.verbose: for name in l: - print ' %s' % name - print '--------------------------------------' - print ' %i tests found' % len(l) - print + print(' %s' % name) + print('--------------------------------------') + print(' %i tests found' % len(l)) + print() def calibrate(self): - print 'Calibrating tests. Please wait...', + print('Calibrating tests. Please wait...', end=' ') if self.verbose: - print - print - print 'Test min max' - print '-' * LINE - tests = self.tests.items() - tests.sort() + print() + print() + print('Test min max') + print('-' * LINE) + tests = sorted(self.tests.items()) for i in range(len(tests)): name, test = tests[i] test.calibrate_test() if self.verbose: - print '%30s: %6.3fms %6.3fms' % \ + print('%30s: %6.3fms %6.3fms' % \ (name, 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.' + print() + print('Done with the calibration.') else: - print 'done.' - print + print('done.') + print() def run(self): - tests = self.tests.items() - tests.sort() + tests = sorted(self.tests.items()) timer = self.get_timer() - print 'Running %i round(s) of the suite at warp factor %i:' % \ - (self.rounds, self.warp) - print + print('Running %i round(s) of the suite at warp factor %i:' % \ + (self.rounds, self.warp)) + print() self.roundtimes = [] for i in range(self.rounds): if self.verbose: - print ' Round %-25i effective absolute overhead' % (i+1) + print(' Round %-25i effective absolute overhead' % (i+1)) total_eff_time = 0.0 for j in range(len(tests)): name, test = tests[j] if self.verbose: - print '%30s:' % name, + print('%30s:' % name, end=' ') test.run() (eff_time, abs_time, min_overhead) = test.last_timing total_eff_time = total_eff_time + eff_time if self.verbose: - print ' %5.0fms %5.0fms %7.3fms' % \ + print(' %5.0fms %5.0fms %7.3fms' % \ (eff_time * MILLI_SECONDS, abs_time * MILLI_SECONDS, - min_overhead * MILLI_SECONDS) + min_overhead * MILLI_SECONDS)) self.roundtimes.append(total_eff_time) if self.verbose: - print (' ' - ' ------------------------------') - print (' ' + print((' ' + ' ------------------------------')) + print((' ' ' Totals: %6.0fms' % - (total_eff_time * MILLI_SECONDS)) - print + (total_eff_time * MILLI_SECONDS))) + print() else: - print '* Round %i done in %.3f seconds.' % (i+1, - total_eff_time) - print + print('* Round %i done in %.3f seconds.' % (i+1, + total_eff_time)) + print() def stat(self): @@ -583,25 +581,24 @@ class Benchmark: def print_header(self, title='Benchmark'): - print '-' * LINE - print '%s: %s' % (title, self.name) - print '-' * LINE - print - print ' Rounds: %s' % self.rounds - print ' Warp: %s' % self.warp - print ' Timer: %s' % self.timer - print + print('-' * LINE) + print('%s: %s' % (title, self.name)) + print('-' * LINE) + print() + print(' Rounds: %s' % self.rounds) + print(' Warp: %s' % self.warp) + print(' Timer: %s' % self.timer) + print() if self.machine_details: print_machine_details(self.machine_details, indent=' ') - print + print() def print_benchmark(self, hidenoise=0, limitnames=None): - print ('Test ' - ' minimum average operation overhead') - print '-' * LINE - tests = self.tests.items() - tests.sort() + print(('Test ' + ' minimum average operation overhead')) + print('-' * LINE) + tests = sorted(self.tests.items()) total_min_time = 0.0 total_avg_time = 0.0 for name, test in tests: @@ -615,43 +612,42 @@ class Benchmark: min_overhead) = test.stat() total_min_time = total_min_time + min_time total_avg_time = total_avg_time + avg_time - print '%30s: %5.0fms %5.0fms %6.2fus %7.3fms' % \ + print('%30s: %5.0fms %5.0fms %6.2fus %7.3fms' % \ (name, min_time * MILLI_SECONDS, avg_time * MILLI_SECONDS, op_avg * MICRO_SECONDS, - min_overhead *MILLI_SECONDS) - print '-' * LINE - print ('Totals: ' + min_overhead *MILLI_SECONDS)) + print('-' * LINE) + print(('Totals: ' ' %6.0fms %6.0fms' % (total_min_time * MILLI_SECONDS, total_avg_time * MILLI_SECONDS, - )) - print + ))) + print() def print_comparison(self, compare_to, hidenoise=0, limitnames=None): # Check benchmark versions if compare_to.version != self.version: - print ('* Benchmark versions differ: ' + print(('* Benchmark versions differ: ' 'cannot compare this benchmark to "%s" !' % - compare_to.name) - print + compare_to.name)) + print() self.print_benchmark(hidenoise=hidenoise, limitnames=limitnames) return # Print header compare_to.print_header('Comparing with') - print ('Test ' - ' minimum run-time average run-time') - print (' ' - ' this other diff this other diff') - print '-' * LINE + print(('Test ' + ' minimum run-time average run-time')) + print((' ' + ' this other diff this other diff')) + print('-' * LINE) # Print test comparisons - tests = self.tests.items() - tests.sort() + tests = sorted(self.tests.items()) total_min_time = other_total_min_time = 0.0 total_avg_time = other_total_avg_time = 0.0 benchmarks_compatible = self.compatible(compare_to) @@ -704,15 +700,15 @@ class Benchmark: # Benchmark or tests are not comparible min_diff, avg_diff = 'n/a', 'n/a' tests_compatible = 0 - print '%30s: %5.0fms %5.0fms %7s %5.0fms %5.0fms %7s' % \ + print('%30s: %5.0fms %5.0fms %7s %5.0fms %5.0fms %7s' % \ (name, min_time * MILLI_SECONDS, other_min_time * MILLI_SECONDS * compare_to.warp / self.warp, min_diff, avg_time * MILLI_SECONDS, other_avg_time * MILLI_SECONDS * compare_to.warp / self.warp, - avg_diff) - print '-' * LINE + avg_diff)) + print('-' * LINE) # Summarise test results if not benchmarks_compatible or not tests_compatible: @@ -730,7 +726,7 @@ class Benchmark: (other_total_avg_time * compare_to.warp) - 1.0) * PERCENT) else: avg_diff = 'n/a' - print ('Totals: ' + print(('Totals: ' ' %5.0fms %5.0fms %7s %5.0fms %5.0fms %7s' % (total_min_time * MILLI_SECONDS, (other_total_min_time * compare_to.warp/self.warp @@ -740,11 +736,11 @@ class Benchmark: (other_total_avg_time * compare_to.warp/self.warp * MILLI_SECONDS), avg_diff - )) - print - print '(this=%s, other=%s)' % (self.name, - compare_to.name) - print + ))) + print() + print('(this=%s, other=%s)' % (self.name, + compare_to.name)) + print() class PyBenchCmdline(Application): @@ -823,8 +819,8 @@ python pybench.py -s p25.pybench -c p21.pybench limitnames = self.values['-t'] if limitnames: if _debug: - print '* limiting test names to one with substring "%s"' % \ - limitnames + print('* limiting test names to one with substring "%s"' % \ + limitnames) limitnames = re.compile(limitnames, re.I) else: limitnames = None @@ -833,26 +829,26 @@ python pybench.py -s p25.pybench -c p21.pybench calibration_runs = self.values['-C'] timer = self.values['--timer'] - print '-' * LINE - print 'PYBENCH %s' % __version__ - print '-' * LINE - print '* using %s %s' % ( + print('-' * LINE) + print('PYBENCH %s' % __version__) + print('-' * LINE) + print('* using %s %s' % ( platform.python_implementation(), - string.join(string.split(sys.version), ' ')) + ' '.join(sys.version.split()))) # Switch off garbage collection if not withgc: try: import gc except ImportError: - print '* Python version doesn\'t support garbage collection' + print('* Python version doesn\'t support garbage collection') else: try: gc.disable() except NotImplementedError: - print '* Python version doesn\'t support gc.disable' + print('* Python version doesn\'t support gc.disable') else: - print '* disabled garbage collection' + print('* disabled garbage collection') # "Disable" sys check interval if not withsyscheck: @@ -861,18 +857,18 @@ python pybench.py -s p25.pybench -c p21.pybench try: sys.setcheckinterval(value) except (AttributeError, NotImplementedError): - print '* Python version doesn\'t support sys.setcheckinterval' + 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: import systimes - print '* using timer: systimes.processtime (%s)' % \ - systimes.SYSTIMES_IMPLEMENTATION + print('* using timer: systimes.processtime (%s)' % \ + systimes.SYSTIMES_IMPLEMENTATION) else: - print '* using timer: %s' % timer + print('* using timer: %s' % timer) - print + print() if compare_to: try: @@ -882,9 +878,9 @@ python pybench.py -s p25.pybench -c p21.pybench f.close() compare_to = bench except IOError as reason: - print '* Error opening/reading file %s: %s' % ( + print('* Error opening/reading file %s: %s' % ( repr(compare_to), - reason) + reason)) compare_to = None if show_bench: @@ -902,16 +898,16 @@ python pybench.py -s p25.pybench -c p21.pybench bench.print_benchmark(hidenoise=hidenoise, limitnames=limitnames) except IOError as reason: - print '* Error opening/reading file %s: %s' % ( + print('* Error opening/reading file %s: %s' % ( repr(show_bench), - reason) - print + reason)) + print() return if reportfile: - print 'Creating benchmark: %s (rounds=%i, warp=%i)' % \ - (reportfile, rounds, warp) - print + print('Creating benchmark: %s (rounds=%i, warp=%i)' % \ + (reportfile, rounds, warp)) + print() # Create benchmark object bench = Benchmark(reportfile, @@ -925,9 +921,9 @@ python pybench.py -s p25.pybench -c p21.pybench bench.calibrate() bench.run() except KeyboardInterrupt: - print - print '*** KeyboardInterrupt -- Aborting' - print + print() + print('*** KeyboardInterrupt -- Aborting') + print() return bench.print_header() if compare_to: @@ -948,12 +944,12 @@ python pybench.py -s p25.pybench -c p21.pybench pickle.dump(bench,f) f.close() except IOError as reason: - print '* Error opening/writing reportfile' + print('* Error opening/writing reportfile') except IOError as reason: - print '* Error opening/writing reportfile %s: %s' % ( + print('* Error opening/writing reportfile %s: %s' % ( reportfile, - reason) - print + reason)) + print() if __name__ == '__main__': PyBenchCmdline() diff --git a/Tools/pybench/systimes.py b/Tools/pybench/systimes.py index 13bed2f..fb3d3b5 100644 --- a/Tools/pybench/systimes.py +++ b/Tools/pybench/systimes.py @@ -185,27 +185,27 @@ def some_workload(): x = x + 1 def test_workload(): - print 'Testing systimes() under load conditions' + print('Testing systimes() under load conditions') t0 = systimes() some_workload() t1 = systimes() - print 'before:', t0 - print 'after:', t1 - print 'differences:', (t1[0] - t0[0], t1[1] - t0[1]) - print + print('before:', t0) + print('after:', t1) + print('differences:', (t1[0] - t0[0], t1[1] - t0[1])) + print() def test_idle(): - print 'Testing systimes() under idle conditions' + print('Testing systimes() under idle conditions') t0 = systimes() time.sleep(1) t1 = systimes() - print 'before:', t0 - print 'after:', t1 - print 'differences:', (t1[0] - t0[0], t1[1] - t0[1]) - print + print('before:', t0) + print('after:', t1) + print('differences:', (t1[0] - t0[0], t1[1] - t0[1])) + print() if __name__ == '__main__': - print 'Using %s as timer' % SYSTIMES_IMPLEMENTATION - print + print('Using %s as timer' % SYSTIMES_IMPLEMENTATION) + print() test_workload() test_idle() |