Guest User

Untitled

a guest
Jun 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import os, glob
  2. import subprocess
  3.  
  4. path = 'cases/ex/'
  5. if len(sys.argv) > 1:
  6. path = sys.argv[1]
  7.  
  8. files = glob.glob(os.path.join(path, '*.txt'))
  9. times = []
  10. times_all = {}
  11. run_no_times = 5
  12.  
  13. for sudoku in files:
  14. one_sum = 0
  15. for x in range(1,run_no_times+1):
  16. output,error = subprocess.Popen(['time', './a.out', sudoku],
  17. stdout=subprocess.PIPE,
  18. stderr=subprocess.PIPE).communicate()
  19. [real] = error.strip().split()[:1]
  20. times_all[(sudoku,x)] = float(real)
  21. one_sum = one_sum + float(real)
  22.  
  23. one_avg = one_sum/run_no_times
  24. print "%s average: %f" % (sudoku, one_avg)
  25. times.append(one_avg)
  26.  
  27.  
  28. total = sum(times)
  29. avg = total/len(times)
  30.  
  31. print 'Average: %f' % avg
Add Comment
Please, Sign In to add comment