コード例 #1
0
def measureOnly(a,t,ms):
   for i in range(1,runs):
      cmd = cmdWithArg(t,a)
      with open( outName(i), 'w') as of:

         # pass the test data file to program stdin
         if testdata.get(testname,None):
            dfName = dataName(testdata[testname],a)
            with open(dfName,'r') as df:
               m = measure(a,qsplit(cmd),delay,maxtime,of,STDOUT,df,
                  logger=logger,affinitymask=affinitymask)

         # pass the test value as a command line argument in cmd
         else:
               m = measure(a,qsplit(cmd),delay,maxtime,of,STDOUT,
                  logger=logger,affinitymask=affinitymask)

         # add to the measurements
         ms.append(m)

      sys.stdout.write('.'); sys.stdout.flush()
      loggerLine.write('.')
コード例 #2
0
ファイル: bencher.py プロジェクト: greatmazinger/pybenchmarks
def measureOnly(a,t,ms):
   for i in range(1,runs):
      cmd = cmdWithArg(t,a)
      with open( outName(i), 'w') as of:

         # pass the test data file to program stdin
         if testdata.get(testname,None):
            dfName = dataName(testdata[testname],a)
            with open(dfName,'r') as df:
               m = measure(a,qsplit(cmd),delay,maxtime,of,STDOUT,df,
                  logger=logger,affinitymask=affinitymask)

         # pass the test value as a command line argument in cmd
         else:
               m = measure(a,qsplit(cmd),delay,maxtime,of,STDOUT,
                  logger=logger,affinitymask=affinitymask)

         # add to the measurements
         ms.append(m)

      sys.stdout.write('.'); sys.stdout.flush()
      loggerLine.write('.')
コード例 #3
0
def measureCheckAndLogRepeatLargest(p,t,ms):
   repeatTestValue = None

   for a in testvalues:
      cmd = cmdWithArg(t,a)
      ofName = outName(0)

      # a logged Empty record will reveal a bencher failure
      m = Record() 

      try:
         with open(logName(p),'w') as logf:
            with open(ofName,'w') as of:
               # append timestamp to log
               print >>logf, '\n', strftime("%a, %d %b %Y %H:%M:%S GMT", gmtime())

               # append Make output to log
               if hasMake(p.imp):
                  with open( makeName(), 'r') as mf:
                     logf.write( mf.read() ) 

               with open(errName(),'w+') as ef:
                  # append command line showing redirected test data file to log
                  if testdata.get(testname,None):
                     dfName = dataName(testdata[testname],a)
                     print >>logf, '\nCOMMAND LINE:\n', cmd, '<', split(dfName)[1]
                     with open(dfName,'r') as df:
                        m = measure(a,qsplit(cmd),delay,maxtime,of,ef,df,
                           logger=logger,affinitymask=affinitymask)

                  # append command line showing test value argument to log
                  else:
                     print >>logf, '\nCOMMAND LINE:\n', cmd
                     m = measure(a,qsplit(cmd),delay,maxtime,of,ef,
                        logger=logger,affinitymask=affinitymask)

            # check the program output was as expected
            checkAndLog(m,ofName,logf)

            # add to the measurements
            ms.append(m)

            # if there was a problem finding the program just ignore the program output
            if not m.isMissing():
               with open(ofName,'r+') as of:
                  # append diff or ndiff or cmp output to log
                  if m.hasBadOutput():
                     with open(diffName(), 'r') as df:
                        logf.write( df.read() )

                  # append program output to log
                  if isNotChecked(testname):
                     logf.write( '\nPROGRAM OUTPUT NOT CHECKED:\n' )
                     logf.write( of.read() )
                  elif isCheckCmp(testname):
                     logf.write( '\n(BINARY) PROGRAM OUTPUT NOT SHOWN\n' )
                  elif getsize(ofName) > outputmax:
                     of.truncate(outputmax)
                     logf.write( '\n(TRUNCATED) PROGRAM OUTPUT:\n' )
                     logf.write( of.read() )
                  else:
                     logf.write( '\nPROGRAM OUTPUT:\n' )
                     logf.write( of.read() )

                  # append program stderr to log
                  if getsize(errName()):
                     with open(errName(), 'r') as ef:
                        logf.write( '\n' )
                        logf.write( ef.read() )               

         if m.isOkay():
            if m.hasExceeded(cutoff):
               repeatTestValue = None
            else:
               repeatTestValue = a
         else:
            break


      except IOError, err:
         if logger: logger.error(err)

      finally:
コード例 #4
0
ファイル: bencher.py プロジェクト: greatmazinger/pybenchmarks
def measureCheckAndLogRepeatLargest(p,t,ms):
   repeatTestValue = None

   for a in testvalues:
      cmd = cmdWithArg(t,a)
      ofName = outName(0)

      # a logged Empty record will reveal a bencher failure
      m = Record()

      try:
         with open(logName(p),'w') as logf:
            with open(ofName,'w') as of:
               # append timestamp to log
               print >>logf, '\n', strftime("%a, %d %b %Y %H:%M:%S GMT", gmtime())

               # append Make output to log
               if hasMake(p.imp):
                  with open( makeName(), 'r') as mf:
                     logf.write( mf.read() )

               with open(errName(),'w+') as ef:
                  # append command line showing redirected test data file to log
                  if testdata.get(testname,None):
                     dfName = dataName(testdata[testname],a)
                     print >>logf, '\nCOMMAND LINE:\n', cmd, '<', split(dfName)[1]
                     with open(dfName,'r') as df:
                        m = measure(a,qsplit(cmd),delay,maxtime,of,ef,df,
                           logger=logger,affinitymask=affinitymask)

                  # append command line showing test value argument to log
                  else:
                     print >>logf, '\nCOMMAND LINE:\n', cmd
                     m = measure(a,qsplit(cmd),delay,maxtime,of,ef,
                        logger=logger,affinitymask=affinitymask)

            # check the program output was as expected
            checkAndLog(m,ofName,logf)

            # add to the measurements
            ms.append(m)

            # if there was a problem finding the program just ignore the program output
            if not m.isMissing():
               with open(ofName,'r+') as of:
                  # append diff or ndiff or cmp output to log
                  if m.hasBadOutput():
                     with open(diffName(), 'r') as df:
                        logf.write( df.read() )

                  # append program output to log
                  if isNotChecked(testname):
                     logf.write( '\nPROGRAM OUTPUT NOT CHECKED:\n' )
                     logf.write( of.read() )
                  elif isCheckCmp(testname):
                     logf.write( '\n(BINARY) PROGRAM OUTPUT NOT SHOWN\n' )
                  elif getsize(ofName) > outputmax:
                     of.truncate(outputmax)
                     logf.write( '\n(TRUNCATED) PROGRAM OUTPUT:\n' )
                     logf.write( of.read() )
                  else:
                     logf.write( '\nPROGRAM OUTPUT:\n' )
                     logf.write( of.read() )

                  # append program stderr to log
                  if getsize(errName()):
                     with open(errName(), 'r') as ef:
                        logf.write( '\n' )
                        logf.write( ef.read() )

         if m.isOkay():
            if m.hasExceeded(cutoff):
               repeatTestValue = None
            else:
               repeatTestValue = a
         else:
            break


      except IOError, err:
         if logger: logger.error(err)

      finally: