6import isystem.connect
as ic
8EXAMPLE_TRD_FILE_NAME =
"example.trd"
9EXAMPLE_XML_PROFILER_FILE_NAME =
"example_profiler_data.xml"
10EXAMPLE_BIN_PROFILER_FILE_NAME = f
"{EXAMPLE_XML_PROFILER_FILE_NAME}.BIN"
13def export_data(conn_mgr: ic.ConnectionMgr) -> str:
15 Export example.trd data to profiler XML and binary data,
and return path to a created XML file.
16 NOTE: Only export files
if they do
not exists yet.
18 ide_ctrl = ic.CIDEController(conn_mgr)
19 workspace_dir = ide_ctrl.getPath(ic.CIDEController.WORKSPACE_DIR)
20 xml_file_path = os.path.join(workspace_dir, EXAMPLE_XML_PROFILER_FILE_NAME)
21 bin_file_path = os.path.join(workspace_dir, EXAMPLE_BIN_PROFILER_FILE_NAME)
23 if os.path.exists(xml_file_path)
and os.path.exists(bin_file_path):
24 print(
"Profiler data files already exists, nothing to do...")
26 print(
"Exporting .trd data to profiler XML and binary file...")
27 export_cfg = ic.CProfilerExportConfig()
28 export_cfg.setFileName(xml_file_path)
29 fmt = ic.CProfilerXMLExportFormat()
30 fmt.setTimelineBinary(
True)
31 export_cfg.setFormatter(fmt)
32 export_cfg.setSaveTimeline(
True)
34 prof_ctrl = ic.CProfilerController2(conn_mgr, EXAMPLE_TRD_FILE_NAME,
"u")
35 prof_ctrl.waitUntilLoaded(10000, isThrow=
True)
36 prof_ctrl.exportData(export_cfg)
37 prof_ctrl.closeDiscard()
39 assert os.path.exists(xml_file_path)
40 assert os.path.exists(bin_file_path)
41 print(f
"\t{xml_file_path}\n\t{bin_file_path}")