Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, glob
- import subprocess
- path = 'cases/ex/'
- if len(sys.argv) > 1:
- path = sys.argv[1]
- files = glob.glob(os.path.join(path, '*.txt'))
- times = []
- times_all = {}
- run_no_times = 5
- for sudoku in files:
- one_sum = 0
- for x in range(1,run_no_times+1):
- output,error = subprocess.Popen(['time', './a.out', sudoku],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE).communicate()
- [real] = error.strip().split()[:1]
- times_all[(sudoku,x)] = float(real)
- one_sum = one_sum + float(real)
- one_avg = one_sum/run_no_times
- print "%s average: %f" % (sudoku, one_avg)
- times.append(one_avg)
- total = sum(times)
- avg = total/len(times)
- print 'Average: %f' % avg
Add Comment
Please, Sign In to add comment