File: timebothCMP.py
""" run this script under 2.6, for its print statement; it spawns commands that test 2.6 and 3.0 separately, and parses results to compute and display comparisons """ import os reportFull = False py26 = r'C:\Python26\\' py30 = r'C:\Python31\\' # CHANGED textfile = 'large.txt' binaryfile = 'large.bin' # e.g., 'iTunes80164Setup.exe' out26 = [] for line in os.popen('%s\python timeIO.py %s %s' % (py26, textfile, binaryfile)): print line, out26.append(line) out30 = [] for line in os.popen('%s\python timeIO.py %s %s' % (py30, textfile, binaryfile)): print line, out30.append(line) def parseLines(linelist): datalines = [line.split('=>') for line in linelist if '=>' in line] return [(test.strip(), float(time)) for (test, time) in datalines] combined = zip(parseLines(out26), parseLines(out30)) print '\n==Summary==\n' for ((test26, time26), (test30, time30)) in combined: #assert test26 == test30 if test26 != test30: print '**label diff:', test26, test30 # CHANGED timesSlower = time30 / time26 percentTime = time26 / time30 if reportFull: print '\n[%s]' % test26 print '....2.6=%.5f\n....3.0=%.5f' % ( time26, time30) print '....3.1 times slower=%.3f' % timesSlower # CHANGED print '....2.6 time percent=%.3f' % percentTime else: print '%-48s' % ('[%s]' % test26), print '=> 3.1 is %8.3f times slower' % timesSlower # CHANGED