sout, serr = device.profile_cmd("cd " + remote_dir + " && " + device.get_pre_argv() + " ./" + self._exe_name + " " + case.get_cmdline()) stdout += "\t" + sout.replace('\n', '\n\t') stderr += "\t" + serr.replace('\n', '\n\t') outfile = os.path.join(reports_dir, case_id + "_" + str(k) + ".log") sout, serr = device.copy_from_device(src = os.path.join(remote_dir, "profile_report.log"), dst=outfile) stdout += sout.replace('\n', '\n\t') stderr += serr.replace('\n', '\n\t') if serr == "": outfiles[case_id][device_id].append(outfile) except (KeyboardInterrupt): print "KeyboardInterrupt in executor.Executor.run()" sys.exit() except: raise sout, serr = device.exec_cmd("rm -rf " + remote_dir) stdout += sout.replace('\n', '\n\t') stderr += serr.replace('\n', '\n\t') self._write_stdout_stderr(reports_dir, stdout, stderr) return outfiles if __name__ == "__main__": cases = CaseSet() cases.parse_xml("x.xml") d = Device("[email protected]", "ssh") e = Executor("ddp_udc_profiling_armv7int_neon_dlb_profile", d, cases) e.run()
def main(): # parse command line option = parse_cmdline() filtered_devices_id = option.devices is_list_devices = int(option.list_devices) filtered_cases_id = option.cases is_list_cases = int(option.list_cases) case_file = option.case_file executable = option.executable # check command line if is_list_devices: list_devices(is_list_devices) return if is_list_cases: list_cases(is_list_cases) return if not os.path.isfile(executable): print "Error: " + executable + " doesn't exist." return # parse cases all_cases = CaseSet() if (case_file != ""): all_cases.parse_xml(os.path.join(os.path.dirname(__file__), case_file)) else: all_cases.parse_xml_dir(os.path.join(os.path.dirname(__file__), "..", "cases")) filtered_case_set = {} if filtered_cases_id: for c in filtered_cases_id: if c in all_cases.keys(): filtered_case_set[c] = all_cases[c] else: print "Warning: " + c + " is not an legal case ID." else: filtered_case_set = all_cases # parse devices all_devices = DeviceSet() all_devices.parse_xml(os.path.join(os.path.dirname(__file__), "..", "devices", "devices.xml")) filtered_device_set = {} for d in filtered_devices_id: if d in all_devices.keys(): filtered_device_set[d] = all_devices[d] else: print "Warning: " + d + " is not an legal device ID." # execute profiling e = Executor(executable, filtered_device_set, filtered_case_set, duplicate=10) try: logfiles = e.run() except (KeyboardInterrupt): print "KeyboardInterrupt in run.main()" sys.exit() # analyze log for case_id in logfiles.keys(): for device_id in logfiles[case_id].keys(): case = all_cases[case_id] root_node = case.get_root_node() coeff = case.get_mcps_norm_coeff() interest_nodes = option.interest_nodes ana = Analyzer(root_node, coeff, interest_nodes) if len(logfiles[case_id][device_id]) > 0: ana.run(logfiles[case_id][device_id]) print "Finished! \nSee profile logs here: " for dir in e.get_reports_dir(): print "\t./" + dir