def extract(output, extracted_params): rows = [ 0 ] * len(extracted_params) for i in range(len(extracted_params)): p = re.compile(extracted_params[i] + '\d+(\.\d+)?') rows[i] = [] for it in p.finditer(output): substring = it.group() # print substring p = re.compile('\d+(\.\d+)?') rows[i].append( config_parse.convert(p.search(substring).group()) ) # return non empty rows return zip(*rows)
def elaborate_data(elaborate, config, invariants): print("==== Starting data elaboration ====") # extract the input file name input_file = do_manual_substitution(elaborate.input_file.currValue(), config) print("\t*** The skeleton for input files is: %s ***" % input_file) dir_skel = os.path.dirname(input_file) file_skel = os.path.basename(input_file) # create an iterator through all the directories spawned by this benchmark dc = configuration.Configuration() for param_name in extract_parameters(dir_skel): dc += config.parameters[param_name] fc = configuration.Configuration() for param_name in extract_parameters(file_skel): fc += config.parameters[param_name] # now iterate through all the directories for it in iterator.ConfigIterator(dc, invariants): # for each directory we list the files and look for files which have been generated by the benchmark curr_dir = dir_skel.format(**it.parameters) print("\t*** Looking up directory: %s ***" % curr_dir) for file in os.listdir(curr_dir): if not file.startswith('~'): # skip raw files continue print("\t\t-> Opening file:", file) p = re.compile('-{0,1}[a-zA-Z0-9]+') file_name_vals = [ config_parse.convert(x.group()) for x in p.finditer(os.path.splitext(file)[0]) ] # check number of arguments in file name if len(file_name_vals) != len(fc): print( '\t\t\t# Wrong number of elements in file name: found %d expected %d #, skipping file!' % (len(file_name_vals), len(fc))) continue # if the number of args is correct we now set the configuration values i = 0 for param_name in fc.parameter_keys(): fc.parameters[param_name].setValue(file_name_vals[i]) i += 1
def elaborate_data(elaborate, config, invariants): print ("==== Starting data elaboration ====") # extract the input file name input_file = do_manual_substitution(elaborate.input_file.currValue(), config) print ("\t*** The skeleton for input files is: %s ***" % input_file) dir_skel = os.path.dirname(input_file) file_skel = os.path.basename(input_file) # create an iterator through all the directories spawned by this benchmark dc = configuration.Configuration() for param_name in extract_parameters(dir_skel): dc += config.parameters[param_name] fc = configuration.Configuration() for param_name in extract_parameters(file_skel): fc += config.parameters[param_name] # now iterate through all the directories for it in iterator.ConfigIterator(dc, invariants): # for each directory we list the files and look for files which have been generated by the benchmark curr_dir = dir_skel.format(**it.parameters) print ("\t*** Looking up directory: %s ***" % curr_dir) for file in os.listdir(curr_dir): if not file.startswith('~'): # skip raw files continue print ("\t\t-> Opening file:", file) p = re.compile('-{0,1}[a-zA-Z0-9]+') file_name_vals = [ config_parse.convert(x.group()) for x in p.finditer(os.path.splitext(file)[0]) ] # check number of arguments in file name if len(file_name_vals) != len(fc): print ('\t\t\t# Wrong number of elements in file name: found %d expected %d #, skipping file!' % (len(file_name_vals), len(fc)) ) continue # if the number of args is correct we now set the configuration values i = 0 for param_name in fc.parameter_keys(): fc.parameters[param_name].setValue(file_name_vals[i]) i+=1