#
#	regression.py
#	created by Firas Shama (shfiras@campus.technion.ac.il), January 2017
#
#	should put the script in the same directory of build, under the eclipse project.
#	to run, simply cd to the project directory with a terminal.
#	run the following command: python regression.py
#	the script will run the graph with 11 different values of cores from 1 to 1024
#	it creates a subdirectory for each run, and copies the output files into it; including:
#	1. rc64.log file
#	2. rc_utilization.csv file
#	3. classification results (mine is called outputClass.txt, rename it below as you wish)
#	4. consoleOut.log file , that include all the prints done from the code.

import sys, string, os, math, shutil
import errno
for i in range(1,12):
	cores = int(math.pow(2,i-1))
	print "running with",cores,"cores"
	dirName = 'cores'+str(cores)
	try:
        	os.makedirs(dirName)
	except OSError as exc: 
        	if exc.errno == errno.EEXIST :
            		pass
        	else:
            		raise	
	os.system("./build/taskgraph"+" -cores="+str(cores)+" -timescale=1 > consoleOut.log")
	
#	shutil.copy("rc64.log", dirName)	it's commented as it's very big file & not used. feel free to uncomment & try
	shutil.copy("rc_utilization.csv", dirName)
	shutil.copy("outputClass.txt", dirName)
	shutil.copy("consoleOut.log", dirName)

