Created
October 22, 2010 01:10
-
-
Save archie/639730 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment